Search in sources :

Example 51 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project selenium_java by sergueik.

the class DesiredCapabilitiesSupplier method get.

@Override
public DesiredCapabilities get() {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.PROXY, proxy);
    return capabilities;
}
Also used : DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities)

Example 52 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project zalenium by zalando.

the class TestUtils method getNewBasicRemoteProxy.

public static DockerSeleniumRemoteProxy getNewBasicRemoteProxy(String browser, String url, GridRegistry registry) throws MalformedURLException {
    GridNodeConfiguration config = new GridNodeConfiguration();
    URL u = new URL(url);
    config.host = u.getHost();
    config.port = u.getPort();
    config.role = "webdriver";
    RegistrationRequest req = RegistrationRequest.build(config);
    req.getConfiguration().capabilities.clear();
    DesiredCapabilities capability = new DesiredCapabilities();
    capability.setBrowserName(browser);
    req.getConfiguration().capabilities.add(capability);
    return createProxy(registry, req);
}
Also used : DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) GridNodeConfiguration(org.openqa.grid.internal.utils.configuration.GridNodeConfiguration) RegistrationRequest(org.openqa.grid.common.RegistrationRequest) URL(java.net.URL)

Example 53 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project zalenium by zalando.

the class ParallelIT method startWebDriverAndGetBaseUrl.

@BeforeMethod(alwaysRun = true)
public void startWebDriverAndGetBaseUrl(Method method, Object[] testArgs) throws MalformedURLException {
    String zaleniumUrl = String.format("http://%s:%s/wd/hub", ZALENIUM_HOST, ZALENIUM_PORT);
    String browserType = testArgs[0].toString();
    Platform platform = (Platform) testArgs[1];
    boolean localTesting = false;
    if (testArgs.length > 2) {
        localTesting = testArgs[2] != null && (boolean) testArgs[2];
    }
    LOGGER.info("STARTING {} on {} - {}, using {}", method.getName(), browserType, platform.name(), zaleniumUrl);
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setCapability(CapabilityType.BROWSER_NAME, browserType);
    desiredCapabilities.setCapability(CapabilityType.PLATFORM_NAME, platform);
    desiredCapabilities.setCapability("name", method.getName());
    if (localTesting) {
        desiredCapabilities.setCapability("tunnel", "true");
        desiredCapabilities.setCapability("browserstack.local", "true");
        desiredCapabilities.setCapability("browserstack.localIdentifier", "zalenium");
        desiredCapabilities.setCapability("tunnelIdentifier", "zalenium");
    }
    try {
        webDriver.set(new RemoteWebDriver(new URL(zaleniumUrl), desiredCapabilities));
    } catch (Exception e) {
        LOGGER.warn("FAILED {} on {} - {}", method.getName(), browserType, platform.name());
        throw e;
    }
}
Also used : Platform(org.openqa.selenium.Platform) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 54 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project zalenium by zalando.

the class CloudProxyHtmlRenderer method tabBrowsers.

// content of the browsers tab
private String tabBrowsers() {
    List<TestSlot> testSlots = proxy.getTestSlots();
    StringBuilder slotLines = new StringBuilder();
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities(testSlots.get(0).getCapabilities());
    String version = desiredCapabilities.getVersion();
    if (version != null) {
        version = "v:" + version;
    }
    Map<String, String> linesValues = new HashMap<>();
    linesValues.put("{{browserVersion}}", version);
    // the lines of icons representing the possible slots
    StringBuilder singleSlotsHtml = new StringBuilder();
    for (TestSlot testSlot : testSlots) {
        singleSlotsHtml.append(getSingleSlotHtml(testSlot));
    }
    linesValues.put("{{singleSlots}}", singleSlotsHtml.toString());
    slotLines.append(templateRenderer.renderSection("{{tabBrowsers}}", linesValues));
    return slotLines.toString();
}
Also used : HashMap(java.util.HashMap) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) TestSlot(org.openqa.grid.internal.TestSlot)

Example 55 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project zalenium by zalando.

the class LiveNodeHtmlRenderer method tabBrowsers.

// content of the browsers tab
private String tabBrowsers() {
    StringBuilder browserSection = new StringBuilder();
    for (TestSlot testSlot : proxy.getTestSlots()) {
        DesiredCapabilities desiredCapabilities = new DesiredCapabilities(testSlot.getCapabilities());
        String icon = getConsoleIconPath(desiredCapabilities);
        String version = desiredCapabilities.getVersion();
        TestSession session = testSlot.getSession();
        String slotClass = "";
        String slotTitle;
        if (session != null) {
            slotClass = "busy";
            slotTitle = session.get("lastCommand") == null ? "" : session.get("lastCommand").toString();
        } else {
            slotTitle = testSlot.getCapabilities().toString();
        }
        Map<String, String> browserValues = new HashMap<>();
        browserValues.put("{{browserVersion}}", Optional.ofNullable(version).orElse("N/A"));
        browserValues.put("{{slotIcon}}", Optional.ofNullable(icon).orElse("N/A"));
        browserValues.put("{{slotClass}}", slotClass);
        browserValues.put("{{slotTitle}}", slotTitle);
        browserSection.append(templateRenderer.renderSection("{{tabBrowsers}}", browserValues));
    }
    return browserSection.toString();
}
Also used : HashMap(java.util.HashMap) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) TestSession(org.openqa.grid.internal.TestSession) TestSlot(org.openqa.grid.internal.TestSlot)

Aggregations

DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)173 File (java.io.File)55 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)40 HashMap (java.util.HashMap)33 URL (java.net.URL)32 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)29 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)28 Test (org.testng.annotations.Test)22 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)20 BeforeClass (org.junit.BeforeClass)19 FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)18 TestSetup (com.coveros.selenified.utilities.TestSetup)17 PhantomJSDriver (org.openqa.selenium.phantomjs.PhantomJSDriver)15 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)14 Before (org.junit.Before)13 Test (org.junit.Test)13 MalformedURLException (java.net.MalformedURLException)12 WebDriver (org.openqa.selenium.WebDriver)12 Actions (org.openqa.selenium.interactions.Actions)12 Dimension (org.openqa.selenium.Dimension)11