use of org.openqa.selenium.remote.DesiredCapabilities in project scout.rt by eclipse.
the class SeleniumDriver method setUpDriver.
public static WebDriver setUpDriver() {
// web-driver executable
String webdriverChromeDriver = System.getProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY);
if (StringUtility.isNullOrEmpty(webdriverChromeDriver)) {
webdriverChromeDriver = OS.isFamilyWindows() ? "/seleniumDrivers/chromedriver.exe" : "/seleniumDrivers/chromedriver";
}
File chromeDriver = new File(webdriverChromeDriver);
if (!chromeDriver.exists()) {
System.out.println("Chrome driver executable not found at path: " + chromeDriver);
URL webdriverChromeDriverResource = SeleniumDriver.class.getResource(webdriverChromeDriver);
if (webdriverChromeDriverResource != null) {
chromeDriver = new File(webdriverChromeDriverResource.getFile());
webdriverChromeDriver = chromeDriver.getAbsolutePath();
}
}
if (!StringUtility.matches(webdriverChromeDriver, ".+\\.exe", Pattern.CASE_INSENSITIVE) && chromeDriver.exists() && !chromeDriver.canExecute()) {
chromeDriver.setExecutable(true);
}
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, webdriverChromeDriver);
logProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, webdriverChromeDriver);
// log-file for web-driver
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File logFile = new File(tmpDir, "webdriver.log");
String logFilePath = logFile.getAbsolutePath();
System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, logFilePath);
logProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, logFilePath);
// set web-driver in verbose mode
System.setProperty(ChromeDriverService.CHROME_DRIVER_VERBOSE_LOG_PROPERTY, "true");
logProperty(ChromeDriverService.CHROME_DRIVER_VERBOSE_LOG_PROPERTY, "true");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
// Prepare options
ChromeOptions options = new ChromeOptions();
String chromeBinary = System.getProperty("chrome.binary");
logProperty("chrome.binary", chromeBinary);
if (StringUtility.hasText(chromeBinary)) {
options.setBinary(chromeBinary);
}
options.addArguments("--lang=en");
options.addArguments("--verbose");
options.addArguments("--disable-infobars");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
// Set logging preferences (see BrowserLogRule)
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
// TODO [7.0] BSH Remove workaround, when Chrome bug is fixed
// <WORKAROUND> https://bugs.chromium.org/p/chromedriver/issues/detail?id=1552
Map<String, String> env = new HashMap<>();
env.put("LANG", "en_US.UTF-8");
System.out.println("Using custom environment variables for driver: " + new JSONObject(env).toString(2));
RemoteWebDriver driver = new ChromeDriver(new ChromeDriverService.Builder().usingAnyFreePort().withEnvironment(// <--
env).build(), capabilities);
// RemoteWebDriver driver = new ChromeDriver(options)
// </WORKAROUND>
driver.manage().timeouts().setScriptTimeout(10000, TimeUnit.SECONDS);
// Set window size roughly to the minimal supported screen size
// (1280x1024 minus some borders for browser toolbar and windows taskbar)
// Add extra 50 pixel height, because of yellow bar "Chrome is being controlled..." which comes up since v 65.0.3325
// even tough the disable-infobars property is set - doesn't work anymore :-(
driver.manage().window().setPosition(new Point(0, 0));
driver.manage().window().setSize(new Dimension(1200, 900 + 50));
Capabilities caps = driver.getCapabilities();
System.out.println("Selenium driver configured with driver=" + driver.getClass().getName() + " browser.name=" + caps.getBrowserName() + " browser.version=" + caps.getVersion());
return driver;
}
use of org.openqa.selenium.remote.DesiredCapabilities in project carina by qaprosoft.
the class IECapabilities method getCapability.
public DesiredCapabilities getCapability(String testName) {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities = initBaseCapabilities(capabilities, BrowserType.IE, testName);
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(CapabilityType.TAKES_SCREENSHOT, false);
return capabilities;
}
use of org.openqa.selenium.remote.DesiredCapabilities in project carina by qaprosoft.
the class MobileCapabilies method getCapability.
@Override
public DesiredCapabilities getCapability(String testName) {
DesiredCapabilities capabilities = new DesiredCapabilities();
// add capabilities based on dynamic _config.properties variables
capabilities = initCapabilities(capabilities);
return capabilities;
}
use of org.openqa.selenium.remote.DesiredCapabilities in project ANNIS by korpling.
the class AcceptanceTest method runKickstarter.
@BeforeClass
public static void runKickstarter() {
try {
runner = new KickstartRunner(WEB_PORT, SERVICE_PORT);
runner.startService();
runner.startJetty();
// get all installed corpora
for (AnnisCorpus c : runner.getCorpora()) {
corpora.add(c.getName());
}
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("takesScreenshot", true);
driver = new PhantomJSDriver(caps);
driver.manage().window().setSize(new Dimension(1024, 768));
} catch (Exception ex) {
log.error(null, ex);
runner = null;
}
}
use of org.openqa.selenium.remote.DesiredCapabilities in project vertx-openshift-it by cescoffier.
the class PhantomJSDeployment method connectToWebService.
public WebDriver connectToWebService() {
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
driver = new RemoteWebDriver(getUrl(), capabilities);
driver.manage().window().setSize(new Dimension(1920, 1080));
return driver;
}
Aggregations