use of org.openqa.selenium.chrome.ChromeDriver in project selenium_java by sergueik.
the class NgMultiSelectTest method setUp.
@Before
public void setUp() throws Exception {
// change according to platform
// NOTE:
// java.lang.IllegalStateException: The driver executable does not exist: /var/run/chromedriver
// java.lang.IllegalStateException: The driver is not executable: /var/run/chromedriver
System.setProperty("webdriver.chrome.driver", osName.toLowerCase().startsWith("windows") ? new File("c:/java/selenium/chromedriver.exe").getAbsolutePath() : resolveEnvVars(chromeDriverPath));
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
if (isMobile) {
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceName", "Google Nexus 5");
Map<String, Object> chromeOptions = new HashMap<>();
chromeOptions.put("mobileEmulation", mobileEmulation);
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
seleniumDriver = new ChromeDriver(capabilities);
// set ignoreSynchronization to true to handle page sync ourselves
// instead of using waitForAngular call in JProtractor
ngDriver = new NgWebDriver(seleniumDriver, true);
} else {
seleniumDriver = new ChromeDriver(capabilities);
ngDriver = new NgWebDriver(seleniumDriver);
}
ngDriver.get(baseUrl);
ngDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
page = new NgMultiSelectPage();
page.setDriver(ngDriver);
JPageFactory.initElements(ngDriver, channel, page);
}
use of org.openqa.selenium.chrome.ChromeDriver in project selenium_java by sergueik.
the class NgQualityShepherdTest method setUp.
@Before
public void setUp() throws Exception {
// change according to platformm
System.setProperty("webdriver.chrome.driver", osName.toLowerCase().startsWith("windows") ? new File("c:/java/selenium/chromedriver.exe").getAbsolutePath() : resolveEnvVars(chromeDriverPath));
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
if (isMobile) {
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceName", "Google Nexus 5");
Map<String, Object> chromeOptions = new HashMap<>();
chromeOptions.put("mobileEmulation", mobileEmulation);
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
seleniumDriver = new ChromeDriver(capabilities);
// set ignoreSynchronization to true to handle page sync ourselves
// instead of using waitForAngular call in JProtractor
ngDriver = new NgWebDriver(seleniumDriver, true);
} else {
seleniumDriver = new ChromeDriver(capabilities);
ngDriver = new NgWebDriver(seleniumDriver);
}
ngDriver.get(baseUrl);
ngDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
page = new NgQualityShepherdPage();
page.setDriver(ngDriver);
JPageFactory.initElements(ngDriver, channel, page);
}
use of org.openqa.selenium.chrome.ChromeDriver in project selenium_java by sergueik.
the class AppTest method setupBeforeSuite.
@BeforeSuite(alwaysRun = true)
public void setupBeforeSuite(ITestContext context) throws InterruptedException, MalformedURLException {
selenium_host = context.getCurrentXmlTest().getParameter("selenium.host");
selenium_port = context.getCurrentXmlTest().getParameter("selenium.port");
selenium_browser = context.getCurrentXmlTest().getParameter("selenium.browser");
selenium_run = context.getCurrentXmlTest().getParameter("selenium.run");
// Remote Configuration
if (selenium_browser.compareToIgnoreCase("remote") == 0) {
String hub = "http://" + selenium_host + ":" + selenium_port + "/wd/hub";
LoggingPreferences logging_preferences = new LoggingPreferences();
logging_preferences.enable(LogType.BROWSER, Level.ALL);
logging_preferences.enable(LogType.CLIENT, Level.INFO);
logging_preferences.enable(LogType.SERVER, Level.INFO);
if (selenium_browser.compareToIgnoreCase("chrome") == 0) {
DesiredCapabilities capabilities = new DesiredCapabilities("chrome", "", Platform.ANY);
capabilities.setBrowserName("chrome");
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logging_preferences);
try {
driver = new RemoteWebDriver(new URL("http://" + selenium_host + ":" + selenium_port + "/wd/hub"), capabilities);
} catch (MalformedURLException ex) {
}
} else {
DesiredCapabilities capabilities = new DesiredCapabilities("firefox", "", Platform.ANY);
capabilities.setBrowserName("firefox");
FirefoxProfile profile = new ProfilesIni().getProfile("default");
capabilities.setCapability("firefox_profile", profile);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logging_preferences);
try {
driver = new RemoteWebDriver(new URL("http://" + selenium_host + ":" + selenium_port + "/wd/hub"), capabilities);
} catch (MalformedURLException ex) {
}
}
} else // standalone
{
if (selenium_browser.compareToIgnoreCase("chrome") == 0) {
System.setProperty("webdriver.chrome.driver", "c:/java/selenium/chromedriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
LoggingPreferences logging_preferences = new LoggingPreferences();
logging_preferences.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logging_preferences);
/*
prefs.js:user_pref("extensions.logging.enabled", true);
user.js:user_pref("extensions.logging.enabled", true);
*/
driver = new ChromeDriver(capabilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
} else {
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
LoggingPreferences logging_preferences = new LoggingPreferences();
logging_preferences.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logging_preferences);
driver = new FirefoxDriver(capabilities);
}
}
try {
driver.manage().window().setSize(new Dimension(600, 800));
driver.manage().timeouts().pageLoadTimeout(50, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
} catch (Exception ex) {
System.out.println(ex.toString());
}
}
use of org.openqa.selenium.chrome.ChromeDriver in project teammates by TEAMMATES.
the class Browser method createWebDriver.
private WebDriver createWebDriver() {
System.out.print("Initializing Selenium: ");
String browser = TestProperties.BROWSER;
if ("firefox".equals(browser)) {
System.out.println("Using Firefox.");
String firefoxPath = TestProperties.FIREFOX_PATH;
if (!firefoxPath.isEmpty()) {
System.out.println("Custom path: " + firefoxPath);
System.setProperty("webdriver.firefox.bin", firefoxPath);
}
// Allow CSV files to be download automatically, without a download popup.
// This method is used because Selenium cannot directly interact with the download dialog.
// Taken from http://stackoverflow.com/questions/24852709
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.panel.shown", false);
profile.setPreference("browser.helperApps.neverAsk.openFile", "text/csv,application/vnd.ms-excel");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv,application/vnd.ms-excel");
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir", System.getProperty("java.io.tmpdir"));
return new FirefoxDriver(profile);
} else if ("chrome".equals(browser)) {
System.out.println("Using Chrome with driver path: " + TestProperties.CHROMEDRIVER_PATH);
System.setProperty("webdriver.chrome.driver", TestProperties.CHROMEDRIVER_PATH);
ChromeOptions options = new ChromeOptions();
options.addArguments("--allow-file-access-from-files");
return new ChromeDriver(options);
}
System.out.println("Using " + browser + " is not supported!");
return null;
}
use of org.openqa.selenium.chrome.ChromeDriver in project browsermator by pcalkins.
the class RunASingleTest method FallbackDriver.
public void FallbackDriver(String fallbackdriver) {
if ("HTMLUnit".equals(fallbackdriver)) {
STAppData.setTargetBrowser("Silent Mode (HTMLUnit)");
STAppFrame.setTargetBrowserView("Silent Mode (HTMLUnit)");
driver = new HtmlUnitDriver();
} else {
STAppData.setTargetBrowser("Chrome 49");
STAppFrame.setTargetBrowserView("Chrome 49");
ChromeOptions optionsfallback49 = new ChromeOptions();
optionsfallback49.setBinary(chrome_path);
System.setProperty("webdriver.chrome.driver", WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver-winxp.exe");
driver = new ChromeDriver(optionsfallback49);
}
}
Aggregations