List of usage examples for org.openqa.selenium.remote RemoteWebDriver RemoteWebDriver
public RemoteWebDriver(URL remoteAddress, Capabilities capabilities)
From source file:com.denimgroup.threadfix.selenium.tests.BaseTest.java
License:Mozilla Public License
public BaseTest(String browser) { if (browser.equals("chrome")) { String location = BaseTest.class.getClassLoader().getResource("Drivers").getFile(); String log = ""; if (System.getProperty("os.name").startsWith("Windows")) { location = location + "/chromedriver.exe"; log = "NUL"; } else {// w ww . j av a 2s .c o m location = location + "/chromedriver"; log = "/dev/null"; } service = new ChromeDriverService.Builder().usingDriverExecutable(new File(location)).usingAnyFreePort() .withLogFile(new File(log)).build(); try { service.start(); } catch (IOException e) { e.printStackTrace(); } driver = new RemoteWebDriver(service.getUrl(), DesiredCapabilities.chrome()); } if (browser.equals("firefox")) { driver = new FirefoxDriver(); } if (browser.equals("IE")) { String location = BaseTest.class.getClassLoader().getResource("Drivers").getFile(); location = location + "/IEDriverServer.exe"; DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); driver = new InternetExplorerDriver(capabilities); } }
From source file:com.digitalpebble.stormcrawler.protocol.selenium.RemoteDriverProtocol.java
License:Apache License
@Override public void configure(Config conf) { super.configure(conf); // see https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setJavascriptEnabled(true); String userAgentString = getAgentString(conf); // custom capabilities Map<String, Object> confCapabilities = (Map<String, Object>) conf.get("selenium.capabilities"); if (confCapabilities != null) { Iterator<Entry<String, Object>> iter = confCapabilities.entrySet().iterator(); while (iter.hasNext()) { Entry<String, Object> entry = iter.next(); Object val = entry.getValue(); // substitute variable $useragent for the real value if (val instanceof String && "$useragent".equalsIgnoreCase(val.toString())) { val = userAgentString; }//from ww w . j a va 2 s .co m capabilities.setCapability(entry.getKey(), entry.getValue()); } } // load adresses from config List<String> addresses = ConfUtils.loadListFromConf("selenium.addresses", conf); if (addresses.size() == 0) { throw new RuntimeException("No value found for selenium.addresses"); } try { for (String cdaddress : addresses) { RemoteWebDriver driver = new RemoteWebDriver(new URL(cdaddress), capabilities); Timeouts touts = driver.manage().timeouts(); int implicitWait = ConfUtils.getInt(conf, "selenium.implicitlyWait", 0); int pageLoadTimeout = ConfUtils.getInt(conf, "selenium.pageLoadTimeout", -1); int setScriptTimeout = ConfUtils.getInt(conf, "selenium.setScriptTimeout", 0); touts.implicitlyWait(implicitWait, TimeUnit.MILLISECONDS); touts.pageLoadTimeout(pageLoadTimeout, TimeUnit.MILLISECONDS); touts.setScriptTimeout(setScriptTimeout, TimeUnit.MILLISECONDS); drivers.add(driver); } } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.econcept.selenium.driver.ChromeImplDriver.java
License:Open Source License
@Override public void setup() throws Exception { // Create service out of builder mService = new ChromeDriverService.Builder().usingDriverExecutable(new File(mExecutablePath)) .usingAnyFreePort().build(); // If there is problem within service, terminate the program try {//from w w w.j a v a2 s . c o m mService.start(); mDriver = new RemoteWebDriver(mService.getUrl(), DesiredCapabilities.chrome()); } // try catch (Exception pExcetpion) { mDriver = null; pExcetpion.printStackTrace(); throw pExcetpion; } // catch }
From source file:com.econcept.selenium.driver.FirefoxImplDriver.java
License:Open Source License
@Override public void setup() throws Exception { // Connect to Selenium Grid // Assign the test DesiredCapabilities lCapability = DesiredCapabilities.firefox(); // Connect webdriver with the test try {//from w ww . j ava2s . c om mDriver = new RemoteWebDriver(new URL(mHubURL), lCapability); } // try catch (MalformedURLException pException) { mDriver = null; throw pException; } // catch }
From source file:com.epam.gepard.selenium.browsers.WebDriverUtil.java
License:Open Source License
/** * By using the default URL, creates a WebDriver object and Selenium object as well. * * @param baseUrl is the default URL for the browser, must not be null! * @return withthe new WebDriver object/*from w w w . j ava2s .co m*/ */ public WebDriver buildWebDriverInstance(final String baseUrl) { if (browserString == null) { throw new SimpleGepardException("No browser to be used was specified."); } DesiredCapabilities capabilities = detectCapabilities(); try { webDriver = new RemoteWebDriver(buildWebDriverUrl(), capabilities); selenium = new WebDriverBackedSelenium(webDriver, baseUrl); selenium.setTimeout(DEFAULT_TIMEOUT); //set the default timeout } catch (WebDriverException | SeleniumException e) { throw new SimpleGepardException(e.getLocalizedMessage()); } // hide all open windows on Mac, it is necessary to hide 'always on top' windows, otherwise useless screenshots will be created from desktop if (getBrowserType() == BrowserEnum.Safari) { selenium.keyPressNative(String.valueOf(KeyEvent.VK_F11)); } return webDriver; }
From source file:com.epam.jdi.uitests.mobile.appium.driver.AppiumDriverFactory.java
License:Open Source License
public String registerDriver(DriverTypes driverType) { switch (runType) { case LOCAL://from www .j a va 2s .co m return registerLocalDriver(driverType); case REMOTE: return registerDriver("Remote " + driverType, () -> new RemoteWebDriver(SauceLabRunner.getSauceUrl(), SauceLabRunner.getSauceDesiredCapabilities(driverType))); } throw exception("Unknown driver: " + driverType); }
From source file:com.example.getstarted.basicactions.UserJourneyTestIT.java
License:Apache License
@Before public void setup() { driver = new RemoteWebDriver(service.getUrl(), DesiredCapabilities.chrome()); }
From source file:com.example.selenium.grid.SeleniumGridChrome.java
@BeforeTest public void setup() throws MalformedURLException { DesiredCapabilities caps = new DesiredCapabilities(); caps.setPlatform(org.openqa.selenium.Platform.WINDOWS); caps = DesiredCapabilities.chrome(); caps.setVersion("56.0.2924.87"); caps.setCapability("chrome.switches", Arrays.asList("--no-default-browser-check")); HashMap<String, String> chromePreferences = new HashMap<String, String>(); chromePreferences.put("profile.password_manager_enabled", "false"); caps.setCapability("chrome.prefs", chromePreferences); driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), caps); //driver.manage().window().maximize(); }
From source file:com.example.selenium.grid.SeleniumGridFireFox.java
@BeforeTest public void setup() throws MalformedURLException { DesiredCapabilities caps = new DesiredCapabilities(); caps.setPlatform(org.openqa.selenium.Platform.WINDOWS); caps = DesiredCapabilities.firefox(); caps.setVersion("45.7.0"); driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), caps); //driver.manage().window().maximize(); }
From source file:com.example.selenium.grid.SeleniumGridIE.java
@BeforeTest public void setup() throws MalformedURLException { DesiredCapabilities caps = new DesiredCapabilities(); caps.setPlatform(org.openqa.selenium.Platform.WINDOWS); caps = DesiredCapabilities.internetExplorer(); caps.setVersion("11.0.33"); caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); caps.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true); caps.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, true); caps.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true); driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), caps); //driver.manage().window().maximize(); }