List of usage examples for org.openqa.selenium.chrome ChromeDriverService createDefaultService
public static ChromeDriverService createDefaultService()
From source file:com.example.getstarted.basicactions.UserJourneyTestIT.java
License:Apache License
@BeforeClass public static void setupClass() throws Exception { service = ChromeDriverService.createDefaultService(); service.start(); }
From source file:com.qmetry.qaf.automation.ui.webdriver.ChromeDriverHelper.java
License:Open Source License
private synchronized void createAndStartService() { if ((service != null) && service.isRunning()) { return;//from www . ja va 2 s.co m } File driverFile = new File(ApplicationProperties.CHROME_DRIVER_PATH.getStringVal("./chromedriver.exe")); if (!driverFile.exists()) { logger.error("Please set webdriver.chrome.driver property properly."); throw new AutomationError("Driver file not exist."); } try { System.setProperty("webdriver.chrome.driver", driverFile.getCanonicalPath()); service = ChromeDriverService.createDefaultService(); service.start(); } catch (IOException e) { logger.error("Unable to start Chrome driver", e); throw new AutomationError("Unable to start Chrome Driver Service ", e); } }
From source file:com.vilt.minium.app.TestConfiguration.java
License:Apache License
@Bean(name = "remoteWebDriverUrl") public URL remoteWebDriverUrl() throws IOException { if (StringUtils.isEmpty(remoteUrl)) { service = ChromeDriverService.createDefaultService(); service.start();//from w w w. j a v a2 s. co m return service.getUrl(); } else { return new URL(remoteUrl); } }
From source file:com.vilt.minium.script.impl.ChromeDriverFactory.java
License:Apache License
protected void maybeInitChromeDriverService() { try {/* w ww .j a v a 2 s. com*/ if (service == null) { String exe = Platform.getCurrent().is(Platform.WINDOWS) ? "chromedriver.exe" : "chromedriver"; File baseWebDriver = new File(new File(preferences.getBaseDir(), "drivers"), exe); if (baseWebDriver.isFile() && baseWebDriver.canExecute()) { service = new ChromeDriverService.Builder().usingDriverExecutable(baseWebDriver) .usingAnyFreePort().build(); } else { service = ChromeDriverService.createDefaultService(); } service.start(); logger.debug("Chrome driver service initialized: {}", service.getUrl()); } } catch (IOException e) { throw Throwables.propagate(e); } }
From source file:org.atteo.moonshine.webdriver.browsers.ChromeBrowser.java
License:Apache License
public ChromeBrowser() { System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, "target/chromedriver.log"); try {//from w w w . jav a2 s . c o m service = ChromeDriverService.createDefaultService(); service.start(); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:org.zanata.page.WebDriverFactory.java
License:Open Source License
private EventFiringWebDriver configureChromeDriver() { System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, PropertiesHolder.getProperty("webdriver.log")); driverService = ChromeDriverService.createDefaultService(); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability("chrome.binary", PropertiesHolder.properties.getProperty("webdriver.chrome.bin")); ChromeOptions options = new ChromeOptions(); URL url = Thread.currentThread().getContextClassLoader() .getResource("zanata-testing-extension/chrome/manifest.json"); assert url != null : "can't find extension (check testResource config in pom.xml)"; File file = new File(url.getPath()).getParentFile(); options.addArguments("load-extension=" + file.getAbsolutePath()); capabilities.setCapability(ChromeOptions.CAPABILITY, options); enableLogging(capabilities);//w w w.j a va 2 s . c o m // start the proxy BrowserMobProxy proxy = new BrowserMobProxyServer(); proxy.start(0); proxy.addFirstHttpFilterFactory( new ResponseFilterAdapter.FilterSource((response, contents, messageInfo) -> { // TODO fail test if response >= 500? if (response.getStatus().code() >= 400) { log.warn("Response {} for URI {}", response.getStatus(), messageInfo.getOriginalRequest().getUri()); } else { log.info("Response {} for URI {}", response.getStatus(), messageInfo.getOriginalRequest().getUri()); } }, 0)); Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy); capabilities.setCapability(CapabilityType.PROXY, seleniumProxy); try { driverService.start(); } catch (IOException e) { throw new RuntimeException("fail to start chrome driver service"); } return new EventFiringWebDriver( new Augmenter().augment(new RemoteWebDriver(driverService.getUrl(), capabilities))); }