use of org.openqa.selenium.chrome.ChromeDriver in project selenium_java by sergueik.
the class BaseTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
// BasicConfigurator.configure();
if (hubUrl == null || hubUrl.trim().isEmpty()) {
// if no hubUrl specified, run the tests on localhost
if (browser == null || browser.trim().isEmpty()) {
// if no browser specified, use IE
driver = new InternetExplorerDriver();
} else {
if (browser.trim().equalsIgnoreCase("firefox")) {
driver = new FirefoxDriver();
} else if (browser.trim().equalsIgnoreCase("chrome")) {
driver = new ChromeDriver();
} else {
driver = new InternetExplorerDriver();
}
}
} else {
DesiredCapabilities capability = new DesiredCapabilities();
capability.setBrowserName(browser);
driver = new RemoteWebDriver(new URL(hubUrl), capability);
}
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
use of org.openqa.selenium.chrome.ChromeDriver in project selenium_java by sergueik.
the class SampleTest method setup.
@BeforeClass
public static void setup() throws IOException {
System.setProperty("webdriver.chrome.driver", (new File("c:/java/selenium/chromedriver.exe")).getAbsolutePath());
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
HashMap<String, Object> chromePrefs = new HashMap<>();
chromePrefs.put("profile.default_content_settings.popups", 0);
String downloadFilepath = System.getProperty("user.dir") + System.getProperty("file.separator") + "target" + System.getProperty("file.separator");
chromePrefs.put("download.default_directory", downloadFilepath);
chromePrefs.put("enableNetwork", "true");
options.setExperimentalOption("prefs", chromePrefs);
for (String optionAgrument : (new String[] { "allow-running-insecure-content", "allow-insecure-localhost", "enable-local-file-accesses", "disable-notifications", /* "start-maximized" , */
"browser.download.folderList=2", "--browser.helperApps.neverAsk.saveToDisk=image/jpg,text/csv,text/xml,application/xml,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/excel,application/pdf", String.format("browser.download.dir=%s", downloadFilepath) /* "user-data-dir=/path/to/your/custom/profile" , */
})) {
options.addArguments(optionAgrument);
}
capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
driver = new ChromeDriver(capabilities);
driver.manage().window().setSize(new Dimension(width, height));
driver.manage().timeouts().pageLoadTimeout(50, TimeUnit.SECONDS).implicitlyWait(implicitWait, TimeUnit.SECONDS).setScriptTimeout(10, TimeUnit.SECONDS);
wait = new WebDriverWait(driver, flexibleWait);
wait.pollingEvery(pollingInterval, TimeUnit.MILLISECONDS);
actions = new Actions(driver);
}
use of org.openqa.selenium.chrome.ChromeDriver in project selenium_java by sergueik.
the class KeyMasterTest method beforeSuiteMethod.
@BeforeSuite
public void beforeSuiteMethod() throws Exception {
// NOTE: CTRL-right click via actions does not work well with Firefox
// driver = new FirefoxDriver();
System.setProperty("webdriver.chrome.driver", "c:/java/selenium/chromedriver.exe");
driver = new ChromeDriver();
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);
wait = new WebDriverWait(driver, flexibleWait);
wait.pollingEvery(pollingInterval, TimeUnit.MILLISECONDS);
actions = new Actions(driver);
}
use of org.openqa.selenium.chrome.ChromeDriver in project selenium_java by sergueik.
the class PageObjectFactoryTest method setUp.
@Before
public void setUp() {
// Create a new instance of a driver
System.setProperty("webdriver.chrome.driver", osName.toLowerCase().startsWith("windows") ? new File("c:/java/selenium/chromedriver.exe").getAbsolutePath() : resolveEnvVars(chromeDriverPath));
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
driver = new ChromeDriver(capabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
ngDriver = new NgWebDriver(driver);
// Navigate to the page
ngDriver.get(baseUrl);
ngDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
use of org.openqa.selenium.chrome.ChromeDriver in project selenium_java by sergueik.
the class NgScrollableTableTest method setUp.
@Before
public void setUp() throws Exception {
// change according to platform
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, true);
}
ngDriver.get(baseUrl);
ngDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
page = new NgScrollableTablePage();
page.setDriver(ngDriver);
JPageFactory.initElements(ngDriver, channel, page);
}
Aggregations