use of org.openqa.selenium.remote.RemoteWebDriver in project acceptance-test-harness by jenkinsci.
the class FallbackConfig method createWebDriver.
private WebDriver createWebDriver(TestName testName) throws IOException {
String browser = System.getenv("BROWSER");
if (browser == null)
browser = "firefox";
browser = browser.toLowerCase(Locale.ENGLISH);
String display = getBrowserDisplay();
switch(browser) {
case "firefox":
FirefoxProfile profile = new FirefoxProfile();
profile.setAlwaysLoadNoFocusLib(true);
profile.setPreference(LANGUAGE_SELECTOR, "en");
// Config screen with many plugins can cause FF to complain JS takes too long to complete - set longer timeout
profile.setPreference(DOM_MAX_SCRIPT_RUN_TIME, (int) getElasticTime().seconds(600));
profile.setPreference(DOM_MAX_CHROME_SCRIPT_RUN_TIME, (int) getElasticTime().seconds(600));
FirefoxBinary binary = new FirefoxBinary();
if (display != null) {
binary.setEnvironmentProperty("DISPLAY", display);
}
return new FirefoxDriver(binary, profile);
case "ie":
case "iexplore":
case "iexplorer":
return new InternetExplorerDriver();
case "chrome":
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", Collections.singletonMap(LANGUAGE_SELECTOR, "en"));
ChromeDriverService.Builder builder = new ChromeDriverService.Builder();
if (display != null) {
builder.withEnvironment(Collections.singletonMap("DISPLAY", display));
}
return new ChromeDriver(builder.build(), options);
case "safari":
return new SafariDriver();
case "htmlunit":
return new HtmlUnitDriver(true);
case "saucelabs":
case "saucelabs-firefox":
DesiredCapabilities caps = DesiredCapabilities.firefox();
caps.setCapability("version", "29");
caps.setCapability("platform", "Windows 7");
caps.setCapability("name", testName.get());
// if running inside Jenkins, expose build ID
String tag = System.getenv("BUILD_TAG");
if (tag != null)
caps.setCapability("build", tag);
return new SauceLabsConnection().createWebDriver(caps);
case "phantomjs":
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
capabilities.setCapability(LANGUAGE_SELECTOR, "en");
capabilities.setCapability(LANGUAGE_SELECTOR_PHANTOMJS, "en");
return new PhantomJSDriver(capabilities);
case "remote-webdriver-firefox":
String u = System.getenv("REMOTE_WEBDRIVER_URL");
if (StringUtils.isBlank(u)) {
throw new Error("remote-webdriver-firefox requires REMOTE_WEBDRIVER_URL to be set");
}
return new RemoteWebDriver(// http://192.168.99.100:4444/wd/hub
new URL(u), DesiredCapabilities.firefox());
default:
throw new Error("Unrecognized browser type: " + browser);
}
}
use of org.openqa.selenium.remote.RemoteWebDriver in project selenium_java by sergueik.
the class ProtractorDriver method init.
@Before
public void init() throws MalformedURLException {
log.info("Launching (protractor) in " + browser + "...");
DesiredCapabilities capabilities = null;
if (browser.toLowerCase().equals("firefox")) {
capabilities = capabilitiesFirefox(capabilities);
} else if (browser.toLowerCase().equals("phantomjs")) {
capabilities = capabilitiesPhantomJS(capabilities);
} else if (browser.toLowerCase().equals("chrome")) {
capabilities = capabilitiesChrome(capabilities);
} else if (browser.toLowerCase().equals("iexplore")) {
capabilities = capabilitiesExplorer(capabilities);
} else if (browser.toLowerCase().equals("android")) {
capabilities = capabilitiesAndroid(capabilities);
} else if (browser.toLowerCase().equals("iphone")) {
capabilities = capabilitiesiPhone(capabilities);
} else if (browser.toLowerCase().equals("ipad")) {
capabilities = capabilitiesiPad(capabilities);
}
if (!location.toLowerCase().contains("local")) {
log.info("Running on Selenium Grid: " + location);
driver = new RemoteWebDriver(new URL(location), capabilities);
} else if (browser.toLowerCase().equals("firefox")) {
driver = new FirefoxDriver(capabilities);
} else if (browser.toLowerCase().equals("phantomjs")) {
driver = new PhantomJSDriver(capabilities);
} else if (browser.toLowerCase().equals("chrome")) {
driver = new ChromeDriver(capabilities);
} else if (browser.toLowerCase().equals("iexplore")) {
driver = new InternetExplorerDriver(capabilities);
} else if (browser.toLowerCase().equals("android")) {
driver = new ChromeDriver(capabilities);
} else if (browser.toLowerCase().equals("iphone")) {
driver = new ChromeDriver(capabilities);
} else if (browser.toLowerCase().equals("ipad")) {
driver = new ChromeDriver(capabilities);
}
ngDriver = new NgWebDriver(driver);
wait = new WebDriverWait(driver, flexibleWait);
wait.pollingEvery(pollingInterval, TimeUnit.MILLISECONDS);
actions = new Actions(driver);
}
use of org.openqa.selenium.remote.RemoteWebDriver in project selenium_java by sergueik.
the class RemoteTest method setupTest.
@Before
public void setupTest() throws MalformedURLException {
DesiredCapabilities capability = DesiredCapabilities.chrome();
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
}
use of org.openqa.selenium.remote.RemoteWebDriver in project selenium_java by sergueik.
the class GridInfoTest method setup.
@BeforeClass
public void setup() throws Exception {
determiner = new ActiveNodeDeterminer();
determiner.setGridPort(PORT);
determiner.setGridHostName(IP);
URL url = new URL("http://" + IP + ":" + PORT + "/wd/hub");
getOsName();
System.setProperty("webdriver.gecko.driver", osName.toLowerCase().startsWith("windows") ? new File("c:/java/selenium/geckodriver.exe").getAbsolutePath() : "/tmp/geckodriver");
System.setProperty("webdriver.firefox.bin", osName.toLowerCase().startsWith("windows") ? new File("c:/Program Files (x86)/Mozilla Firefox/firefox.exe").getAbsolutePath() : "/usr/bin/firefox");
// use legacy FirefoxDriver
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", false);
driver = new RemoteWebDriver(url, capabilities);
}
use of org.openqa.selenium.remote.RemoteWebDriver in project selenium_java by sergueik.
the class SessionTest method beforeClass.
@BeforeClass
public void beforeClass() throws IOException {
getOsName();
if (browser.equals("chrome")) {
capabilities = DesiredCapabilities.chrome();
} else if (browser.equals("firefox")) {
// capabilities = DesiredCapabilities.firefox();
capabilities = new DesiredCapabilities("firefox", "", Platform.ANY);
FirefoxProfile profile = new ProfilesIni().getProfile("default");
capabilities.setCapability("firefox_profile", profile);
}
driver = null;
try {
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"), capabilities);
} catch (MalformedURLException ex) {
}
assertThat(driver, notNullValue());
actions = new Actions(driver);
driver.manage().timeouts().setScriptTimeout(scriptTimeout, TimeUnit.SECONDS);
// Declare a wait time
wait = new WebDriverWait(driver, flexibleWait);
wait.pollingEvery(pollingInterval, TimeUnit.MILLISECONDS);
screenshot = ((TakesScreenshot) driver);
js = ((JavascriptExecutor) driver);
driver.manage().window().setSize(new Dimension(600, 800));
driver.manage().timeouts().pageLoadTimeout(pageLoadTimeout, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(implicitlyWaitTimeout, TimeUnit.SECONDS);
// print the node information
getIPOfNode(driver);
// Go to URL
driver.get(baseURL);
}
Aggregations