Search in sources :

Example 11 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project keycloak by keycloak.

the class KeycloakWebDriverConfigurator method createConfiguration.

public void createConfiguration(@Observes BeforeDroneInstantiated event, DroneContext droneContext) {
    WebDriverConfiguration webDriverCfg = droneContext.get(event.getDronePoint()).getConfigurationAs(WebDriverConfiguration.class);
    DesiredCapabilities capabilitiesToAdd = new DesiredCapabilities();
    updateCapabilityKeys("htmlUnit", webDriverCfg, capabilitiesToAdd);
    updateCapabilityKeys("appium", webDriverCfg, capabilitiesToAdd);
    configurePhantomJSDriver(webDriverCfg, capabilitiesToAdd);
    acceptAllSSLCerts(webDriverCfg, capabilitiesToAdd);
    BrowserCapabilities browserCap = registryInstance.get().getEntryFor(webDriverCfg.getBrowser());
    webDriverCfg.setBrowserInternal(new KcBrowserCapabilities(capabilitiesToAdd, browserCap));
}
Also used : DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) WebDriverConfiguration(org.jboss.arquillian.drone.webdriver.configuration.WebDriverConfiguration) BrowserCapabilities(org.jboss.arquillian.drone.webdriver.spi.BrowserCapabilities)

Example 12 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project NoraUi by NoraUi.

the class DriverFactory method generateGoogleChromeDriver.

/**
 * Generates a chrome webdriver.
 *
 * @return
 *         A chrome webdriver
 * @throws TechnicalException
 *             if an error occured when Webdriver setExecutable to true.
 */
private WebDriver generateGoogleChromeDriver() throws TechnicalException {
    final String pathWebdriver = DriverFactory.getPath(Driver.CHROME);
    if (!new File(pathWebdriver).setExecutable(true)) {
        throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE));
    }
    logger.info("Generating Chrome driver ({}) ...", pathWebdriver);
    System.setProperty(Driver.CHROME.getDriverName(), pathWebdriver);
    final ChromeOptions chromeOptions = new ChromeOptions();
    final DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
    capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
    setLoggingLevel(capabilities);
    if (Context.isHeadless()) {
        chromeOptions.addArguments("--headless");
    }
    // Proxy configuration
    if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
        capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
    }
    setChromeOptions(capabilities, chromeOptions);
    final String withWhitelistedIps = Context.getWebdriversProperties("withWhitelistedIps");
    if (withWhitelistedIps != null && !"".equals(withWhitelistedIps)) {
        final ChromeDriverService service = new ChromeDriverService.Builder().withWhitelistedIps(withWhitelistedIps).withVerbose(false).build();
        return new ChromeDriver(service, capabilities);
    } else {
        return new ChromeDriver(capabilities);
    }
}
Also used : TechnicalException(com.github.noraui.exception.TechnicalException) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) ChromeDriverService(org.openqa.selenium.chrome.ChromeDriverService) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) File(java.io.File)

Example 13 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project archiva by apache.

the class WebdriverUtility method newWebDriver.

public static WebDriver newWebDriver(String seleniumBrowser, String seleniumHost, int seleniumPort, boolean seleniumRemote) {
    log.info("WebDriver {}, {}, {}, {}", seleniumBrowser, seleniumHost, seleniumPort, seleniumRemote);
    if (seleniumRemote && StringUtils.isEmpty(seleniumHost)) {
        throw new IllegalArgumentException("seleniumHost must be set, when seleniumRemote=true");
    }
    try {
        if (StringUtils.contains(seleniumBrowser, "chrome")) {
            ChromeOptions options = new ChromeOptions();
            options.addArguments("start-maximized");
            if (seleniumRemote) {
                DesiredCapabilities capabilities = DesiredCapabilities.chrome();
                capabilities.setCapability(ChromeOptions.CAPABILITY, options);
                return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), capabilities);
            } else {
                return new ChromeDriver(options);
            }
        }
        if (StringUtils.contains(seleniumBrowser, "safari")) {
            if (seleniumRemote) {
                return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.safari());
            } else {
                return new SafariDriver();
            }
        }
        if (StringUtils.contains(seleniumBrowser, "iexplore")) {
            if (seleniumRemote) {
                return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.internetExplorer());
            } else {
                new InternetExplorerDriver();
            }
        }
        if (StringUtils.contains(seleniumBrowser, "firefox")) {
            if (seleniumRemote) {
                return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.firefox());
            } else {
                return new FirefoxDriver();
            }
        }
        DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
        capabilities.setJavascriptEnabled(true);
        capabilities.setVersion("firefox-52");
        WebDriver driver;
        if (seleniumRemote) {
            driver = new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), capabilities);
        } else {
            driver = new HtmlUnitDriver(capabilities) {

                @Override
                protected WebClient modifyWebClient(WebClient client) {
                    client.getOptions().setThrowExceptionOnFailingStatusCode(false);
                    client.getOptions().setThrowExceptionOnScriptError(false);
                    client.getOptions().setCssEnabled(true);
                    return client;
                }
            };
        }
        return driver;
    } catch (MalformedURLException e) {
        throw new RuntimeException("Initializion of remote driver failed");
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) MalformedURLException(java.net.MalformedURLException) InternetExplorerDriver(org.openqa.selenium.ie.InternetExplorerDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) WebClient(com.gargoylesoftware.htmlunit.WebClient) URL(java.net.URL) SafariDriver(org.openqa.selenium.safari.SafariDriver) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver)

Example 14 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project Bytecoder by mirkosertic.

the class BytecoderUnitTestRunner method newDriverForTest.

private WebDriver newDriverForTest() {
    ChromeOptions theOptions = new ChromeOptions();
    theOptions.addArguments("headless");
    theOptions.addArguments("disable-gpu");
    LoggingPreferences theLoggingPreferences = new LoggingPreferences();
    theLoggingPreferences.enable(LogType.BROWSER, Level.ALL);
    theOptions.setCapability(CapabilityType.LOGGING_PREFS, theLoggingPreferences);
    DesiredCapabilities theCapabilities = DesiredCapabilities.chrome();
    theCapabilities.setCapability(ChromeOptions.CAPABILITY, theOptions);
    return new RemoteWebDriver(DRIVERSERVICE.getUrl(), theCapabilities);
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) LoggingPreferences(org.openqa.selenium.logging.LoggingPreferences) ChromeOptions(org.openqa.selenium.chrome.ChromeOptions)

Example 15 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project selenified by Coveros.

the class ActionDoIT method takeScreenshotHtmlUnitTest.

@Test(groups = { "integration", "actions", "screenshot", "do" }, description = "An integration test to check the takeScreenshot method")
public void takeScreenshotHtmlUnitTest() throws InvalidBrowserException, MalformedURLException {
    // use this object to manipulate the app
    App app = new App(Browser.HTMLUNIT, new DesiredCapabilities(), null);
    // perform some actions
    app.takeScreenshot("somefile");
    app.killDriver();
    // verify no issues
    finish();
}
Also used : App(com.coveros.selenified.application.App) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) Test(org.testng.annotations.Test)

Aggregations

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