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));
}
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);
}
}
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");
}
}
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);
}
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();
}
Aggregations