use of org.openqa.selenium.chrome.ChromeDriver in project chrome_page_performance_sqlite_java by sergueik.
the class ChromePagePerformanceObjectTest method beforeClass.
@SuppressWarnings("deprecation")
@BeforeClass
public static void beforeClass() throws IOException {
getOsName();
System.setProperty("webdriver.chrome.driver", osName.toLowerCase().startsWith("windows") ? new File("c:/java/selenium/chromedriver.exe").getAbsolutePath() : "/var/run/chromedriver");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
Map<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 option : (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(option);
}
// options for headless
if (headless) {
// headless option arguments
for (String option : (osName.toLowerCase().startsWith("windows")) ? new String[] { "headless", "disable-gpu", "disable-plugins", "window-size=1200x600", "window-position=-9999,0" } : new String[] { "headless", "disable-gpu", "remote-debugging-port=9222", "window-size=1200x600" }) {
options.addArguments(option);
}
// on Windows need ChromeDriver 2.31 / Chrome 60 to support headless
// With earlier versions of chromedriver: chrome not reachable...
// https://developers.google.com/web/updates/2017/04/headless-chrome
// https://stackoverflow.com/questions/43880619/headless-chrome-and-selenium-on-windows
}
//
capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
driver = new ChromeDriver(capabilities);
try {
// origin:
// https://www.tutorialspoint.com/sqlite/sqlite_java.htm
Class.forName("org.sqlite.JDBC");
// String dbURL = "jdbc:sqlite:performance.db";
conn = DriverManager.getConnection("jdbc:sqlite:performance.db");
if (conn != null) {
// System.out.println("Connected to the database");
DatabaseMetaData databaseMetadata = conn.getMetaData();
System.out.println("Driver name: " + databaseMetadata.getDriverName());
System.out.println("Driver version: " + databaseMetadata.getDriverVersion());
System.out.println("Product name: " + databaseMetadata.getDatabaseProductName());
System.out.println("Product version: " + databaseMetadata.getDatabaseProductVersion());
createNewTable();
// insertData("name", 1.0);
// conn.close();
}
} catch (ClassNotFoundException | SQLException ex) {
ex.printStackTrace();
} finally {
}
assertThat(driver, notNullValue());
}
use of org.openqa.selenium.chrome.ChromeDriver in project ghostdriver by detro.
the class BaseTest method prepareDriver.
@Before
public void prepareDriver() throws Exception {
// Which driver to use? (default "phantomjs")
String driver = sConfig.getProperty("driver", DRIVER_PHANTOMJS);
// Start appropriate Driver
if (isUrl(driver)) {
sCaps.setBrowserName("phantomjs");
mDriver = new RemoteWebDriver(new URL(driver), sCaps);
} else if (driver.equals(DRIVER_FIREFOX)) {
mDriver = new FirefoxDriver(sCaps);
} else if (driver.equals(DRIVER_CHROME)) {
mDriver = new ChromeDriver(sCaps);
} else if (driver.equals(DRIVER_PHANTOMJS)) {
mDriver = new PhantomJSDriver(sCaps);
}
}
use of org.openqa.selenium.chrome.ChromeDriver in project java.webdriver by sayems.
the class GetHeight method main.
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.navigate().to("http://www.google.com");
driver.manage().window().setSize(new Dimension(1024, 768));
driver.quit();
}
use of org.openqa.selenium.chrome.ChromeDriver in project java.webdriver by sayems.
the class GetWindowName method main.
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.navigate().to("http://www.google.com");
JavascriptExecutor js = (JavascriptExecutor) driver;
System.out.println(js.executeScript("return window.name"));
}
use of org.openqa.selenium.chrome.ChromeDriver in project BuildRadiator by BuildRadiator.
the class UrlEditorWebDriverTest method sharedForAllTests.
@BeforeClass
public static void sharedForAllTests() {
// Keep the WebDriver browser window open between tests
ChromeOptions co = new ChromeOptions();
boolean headless = Boolean.parseBoolean(System.getProperty("HEADLESS", "false"));
if (headless) {
co.addArguments("headless");
}
co.addArguments("window-size=1200x800");
DRIVER = new ChromeDriver(co);
FWD = new FluentWebDriver(DRIVER);
}
Aggregations