use of org.openqa.selenium.chrome.ChromeDriver in project browsermator by pcalkins.
the class RunASingleTest method RunSingleTest.
public void RunSingleTest(Procedure bugtorun, ProcedureView thisbugview, String TargetBrowser, String OSType) {
STAppFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
File thisDriver = new File(WEBDRIVERSDIR + "geckodriver-win32" + File.separator + "geckodriver.exe");
switch(TargetBrowser) {
case "Firefox-Marionette":
if ("Windows".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-win32" + File.separator + "geckodriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", "lib"+File.separator+"geckodriver-win32"+File.separator+"geckodriver.exe");
}
if ("Windows32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-win32" + File.separator + "geckodriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", "lib"+File.separator+"geckodriver-win32"+File.separator+"geckodriver.exe");
}
if ("Windows64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-win64" + File.separator + "geckodriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", "lib"+File.separator+"geckodriver-win64"+File.separator+"geckodriver.exe");
}
if ("Mac".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-osx" + File.separator + "geckodriver");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", "lib"+File.separator+"geckodriver-osx"+File.separator+"geckodriver");
}
if ("Linux-32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-linux32" + File.separator + "geckodriver");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", "lib"+File.separator+"geckodriver-linux32"+File.separator+"geckodriver");
}
if ("Linux-64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-linux64" + File.separator + "geckodriver");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", "lib"+File.separator+"geckodriver-linux64"+File.separator+"geckodriver");
}
if (firefox_path != null) {
System.setProperty("webdriver.firefox.bin", firefox_path);
}
try {
// FirefoxProfile profile = new FirefoxProfile();
// DesiredCapabilities cap = DesiredCapabilities.firefox();
// cap.setJavascriptEnabled(true);
// cap.setCapability("marionette", false);
// profile.setPreference("dom.max_script_run_time", 1);
driver = new FirefoxDriver();
// driver = new MarionetteDriver();
} catch (Exception ex) {
System.out.println("Exception launching Marionette driver... possibly XP or missing msvcr110.dll: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the Marionette driver, will fallback to HTMLUnitDriver", false, 0, 0);
FallbackDriver("HTMLUnit");
}
break;
case "Firefox":
if ("Windows".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-win32" + File.separator + "geckodriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
}
if ("Windows32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-win32" + File.separator + "geckodriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
}
if ("Windows64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-win64" + File.separator + "geckodriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", BMPATH+File.separator+"lib"+File.separator+"geckodriver-win64"+File.separator+"geckodriver.exe");
}
if ("Mac".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-osx" + File.separator + "geckodriver");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", BMPATH+File.separator+"lib"+File.separator+"geckodriver-osx"+File.separator+"geckodriver");
}
if ("Linux-32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-linux32" + File.separator + "geckodriver");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver",BMPATH+File.separator+ "lib"+File.separator+"geckodriver-linux32"+File.separator+"geckodriver");
}
if ("Linux-64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-linux64" + File.separator + "geckodriver");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", BMPATH+File.separator+"lib"+File.separator+"geckodriver-linux64"+File.separator+"geckodriver");
}
if (firefox_path != null) {
System.setProperty("webdriver.firefox.bin", firefox_path);
}
try {
// DesiredCapabilities cap = DesiredCapabilities.firefox();
// cap.setJavascriptEnabled(false);
// FirefoxProfile profile = new FirefoxProfile();
// DesiredCapabilities cap = DesiredCapabilities.firefox();
// cap.setJavascriptEnabled(true);
// cap.setCapability("marionette", true);
// profile.setPreference("dom.max_script_run_time", 30);
driver = new FirefoxDriver();
// driver = new MarionetteDriver();
} catch (Exception ex) {
System.out.println("Exception launching Marionette driver... possibly XP or missing msvcr110.dll: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the Marionette driver, will fallback to HTMLUnitDriver", false, 0, 0);
FallbackDriver("HTMLUnit");
}
break;
case "Silent Mode (HTMLUnit)":
driver = new HtmlUnitDriver();
break;
case "Internet Explorer-32":
thisDriver = new File(WEBDRIVERSDIR + "iedriverserver_win32" + File.separator + "IEDriverServer.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.ie.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.ie.driver", BMPATH+File.separator+"lib"+File.separator+"iedriverserver_win32"+File.separator+"IEDriverServer.exe");
try {
driver = new InternetExplorerDriver();
} catch (Exception ex) {
System.out.println("Exception launching Internet Explorer driver: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the IEdriver, will fallback to HTMLUnitDriver", false, 0, 0);
FallbackDriver("HTMLUnit");
}
break;
case "Internet Explorer-64":
thisDriver = new File(WEBDRIVERSDIR + "iedriverserver_win64" + File.separator + "IEDriverServer.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.ie.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.ie.driver",BMPATH+File.separator+ "lib"+File.separator+"iedriverserver_win64"+File.separator+"IEDriverServer.exe");
try {
driver = new InternetExplorerDriver();
} catch (Exception ex) {
System.out.println("Exception launching Internet Explorer-64 driver: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the IEdriver, will fallback to HTMLUnitDriver", false, 0, 0);
FallbackDriver("HTMLUnit");
}
break;
case "Chrome":
// legacy support
ChromeOptions options = new ChromeOptions();
if (chrome_main_path != null) {
options.setBinary(chrome_main_path);
}
if ("Windows".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_win32"+File.separator+"chromedriver.exe");
}
if ("Windows32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_win32"+File.separator+"chromedriver.exe");
}
if ("Windows64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_win32"+File.separator+"chromedriver.exe");
}
if ("Mac".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_mac64" + File.separator + "chromedriver");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_mac64"+File.separator+"chromedriver");
}
if ("Linux-32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_linux32" + File.separator + "chromedriver");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver",BMPATH+File.separator+ "lib"+File.separator+"chromedriver_linux32"+File.separator+"chromedriver");
}
if ("Linux-64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_linux64" + File.separator + "chromedriver");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_linux64"+File.separator+"chromedriver");
}
try {
driver = new ChromeDriver(options);
} catch (Exception ex) {
System.out.println("Problem launching Chromedriver: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the Chromedriver, will fallback to HTMLUnitDriver: " + ex.toString(), false, 0, 0);
FallbackDriver("HTMLUnit");
}
break;
case "Chrome 49":
ChromeOptions options49 = new ChromeOptions();
if (chrome_path != null) {
options49.setBinary(chrome_path);
}
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver-winxp.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
try {
driver = new ChromeDriver(options49);
} catch (Exception ex) {
System.out.println("Problem launching Chromedriver 49: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the Chrome 49 driver, will fallback to HTMLUnitDriver: " + ex.toString(), false, 0, 0);
FallbackDriver("HTMLUnit");
}
break;
case "Edge":
thisDriver = new File(WEBDRIVERSDIR + "edgedriver" + File.separator + "MicrosoftWebDriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.edge.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.edge.driver", BMPATH+File.separator+"lib"+File.separator+"edgedriver"+File.separator+"MicrosoftWebDriver.exe");
try {
driver = new EdgeDriver();
} catch (Exception ex) {
System.out.println("Problem launching EdgeDriver: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the Edge Driver, will fallback to HTMLUnitDriver: " + ex.toString(), false, 0, 0);
FallbackDriver("HTMLUnit");
}
break;
default:
if ("Windows".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver",BMPATH+File.separator+ "lib"+File.separator+"chromedriver_win32"+File.separator+"chromedriver.exe");
}
if ("Windows32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", WEBDRIVERSDIR+"chromedriver_win32"+File.separator+"chromedriver.exe");
}
if ("Windows64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver",BMPATH+File.separator+ "lib"+File.separator+"chromedriver_win32"+File.separator+"chromedriver.exe");
}
if ("Mac".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_mac64" + File.separator + "chromedriver");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_mac64"+File.separator+"chromedriver");
}
if ("Linux-32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_linux32" + File.separator + "chromedriver");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_linux32"+File.separator+"chromedriver");
}
if ("Linux-64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_linux64" + File.separator + "chromedriver");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_linux64"+File.separator+"chromedriver");
}
try {
driver = new ChromeDriver();
} catch (Exception ex) {
System.out.println("Problem launching Chromedriver: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the Chromedriver, will fallback to HTMLUnit Driver: " + ex.toString(), false, 0, 0);
FallbackDriver("HTMLUnit");
}
}
int WaitTime = 0;
WaitTime = STAppData.getWaitTime();
// timeouts still buggy.. removed
// int Timeout = SiteTest.getTimeout();
// int Timeout = 5;
// driver.manage().timeouts().implicitlyWait(Timeout, TimeUnit.SECONDS);
// driver.manage().timeouts().pageLoadTimeout(Timeout, TimeUnit.SECONDS);
// driver.manage().timeouts().setScriptTimeout(Timeout, TimeUnit.SECONDS);
int totalpause = WaitTime * 1000;
if (!"Dataloop".equals(thisbugview.Type)) {
for (Action ThisAction : bugtorun.ActionsList) {
if (STAppData.cancelled) {
publish(bugtorun.index);
break;
}
if (!ThisAction.Locked) {
try {
if (totalpause > 0) {
try {
Thread.sleep(totalpause);
} catch (Exception ex) {
System.out.println("Exception when sleeping: " + ex.toString());
ThisAction.Pass = false;
break;
}
}
String varfieldname = "";
if (ThisAction.Variable2.contains("[stored_varname-start]")) {
varfieldname = ThisAction.Variable2;
int indexof_end_tag = varfieldname.indexOf("[stored_varname-end]");
// assuming name of "[stored_varname-start]" and "[stored_varname-end]"
String fieldname = varfieldname.substring(22, indexof_end_tag);
ThisAction.Variable2 = STAppData.GetStoredVariableValue(fieldname);
ThisAction.RunAction(driver);
ThisAction.Variable2 = "[stored_varname-start]" + fieldname + "[stored_varname-end]";
} else {
if ("Pause with Continue Button".equals(ThisAction.Type)) {
int nothing = ThisAction.RunAction(driver, "Actions Paused...", STAppData, 0, 0);
} else {
ThisAction.RunAction(driver);
}
}
if (!"".equals(ThisAction.tostore_varvalue)) {
STAppData.VarHashMap.put(ThisAction.tostore_varname, ThisAction.tostore_varvalue);
}
if (ThisAction.tostore_varlist.size() > 0) {
STAppData.VarLists.put(ThisAction.Variable2, ThisAction.tostore_varlist);
}
} catch (Exception ex) {
break;
}
} else {
ThisAction.Pass = true;
}
}
} else {
int number_of_rows = thisbugview.DataTable.getRowCount();
for (int x = 0; x < number_of_rows; x++) {
int changex = -1;
for (Action ThisAction : bugtorun.ActionsList) {
if (STAppData.cancelled) {
publish(bugtorun.index);
break;
}
String original_value1 = ThisAction.Variable1;
String original_value2 = ThisAction.Variable2;
if (!ThisAction.Locked) {
DataLoopVarParser var1Parser = new DataLoopVarParser(ThisAction.Variable1);
DataLoopVarParser var2Parser = new DataLoopVarParser(ThisAction.Variable2);
if (var1Parser.hasDataLoopVar == false && var2Parser.hasDataLoopVar == false) {
if ("Pause with Continue Button".equals(ThisAction.Type)) {
String pause_message = "Paused at record " + (x + 1) + " of " + number_of_rows;
changex = ThisAction.RunAction(driver, pause_message, STAppData, x, number_of_rows);
} else
try {
if (totalpause > 0) {
try {
Thread.sleep(totalpause);
} catch (Exception ex) {
System.out.println("Exception when sleeping: " + ex.toString());
ThisAction.Pass = false;
publish(bugtorun.index);
break;
}
}
String varfieldname = "";
if (ThisAction.Variable2.contains("[stored_varname-start]")) {
varfieldname = ThisAction.Variable2;
int indexof_end_tag = varfieldname.indexOf("[stored_varname-end]");
// assuming name of "[stored_varname-start]" and "[stored_varname-end]"
String fieldname = varfieldname.substring(22, indexof_end_tag);
ThisAction.Variable2 = STAppData.GetStoredVariableValue(fieldname);
ThisAction.RunAction(driver);
ThisAction.Variable2 = "[stored_varname-start]" + fieldname + "[stored_varname-end]";
} else {
ThisAction.RunAction(driver);
}
if (!"".equals(ThisAction.tostore_varvalue)) {
STAppData.VarHashMap.put(ThisAction.tostore_varname, ThisAction.tostore_varvalue);
}
} catch (Exception ex) {
ThisAction.Variable1 = original_value1;
ThisAction.Variable2 = original_value2;
break;
}
} else {
String concat_variable = "";
String concat_variable2 = "";
if ("urllist".equals(bugtorun.DataLoopSource)) {
concat_variable = var1Parser.GetFullValueFromURLList(x, bugtorun.URLListData);
}
if ("file".equals(bugtorun.DataLoopSource)) {
concat_variable = var1Parser.GetFullValueFromFile(x, bugtorun.RunTimeFileSet);
}
if (var1Parser.hasDataLoopVar) {
ThisAction.Variable1 = concat_variable;
if ("".equals(ThisAction.Variable1)) {
ThisAction.Variable1 = " ";
}
}
if ("urllist".equals(bugtorun.DataLoopSource)) {
concat_variable2 = var2Parser.GetFullValueFromURLList(x, bugtorun.URLListData);
}
if ("file".equals(bugtorun.DataLoopSource)) {
concat_variable2 = var2Parser.GetFullValueFromFile(x, bugtorun.RunTimeFileSet);
}
if (var2Parser.hasDataLoopVar) {
ThisAction.Variable2 = concat_variable2;
if ("".equals(ThisAction.Variable2)) {
ThisAction.Variable2 = " ";
}
}
try {
if (totalpause > 0) {
try {
Thread.sleep(totalpause);
} catch (Exception ex) {
System.out.println("Exception when sleeping: " + ex.toString());
ThisAction.Pass = false;
break;
}
}
ThisAction.RunAction(driver);
ThisAction.Variable1 = original_value1;
ThisAction.Variable2 = original_value2;
} catch (Exception ex) {
ThisAction.Variable1 = original_value1;
ThisAction.Variable2 = original_value2;
break;
}
}
} else {
ThisAction.Pass = true;
}
}
if (changex != x) {
if (changex == -1) {
} else {
x = changex - 1;
}
}
}
}
if (STAppData.getPromptToClose()) {
Prompter thisContinuePrompt = new Prompter(STAppData.short_filename + " - Prompt to close webdriver", "Close webdriver/browser?", false, 0, 0);
while (thisContinuePrompt.isVisible() == true) {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
System.out.println("pause exception: " + e.toString());
}
}
try {
driver.close();
} catch (Exception e) {
System.out.println(e.toString());
try {
driver.quit();
} catch (Exception ex) {
System.out.println(ex.toString());
}
}
driver.quit();
}
}
use of org.openqa.selenium.chrome.ChromeDriver in project browsermator by pcalkins.
the class RunAllTests method FallbackDriver.
public void FallbackDriver(String fallbackdriver) {
if ("HTMLUnit".equals(fallbackdriver)) {
STAppData.setTargetBrowser("Silent Mode (HTMLUnit)");
if (RUNWITHGUI) {
STAppFrame.setTargetBrowserView("Silent Mode (HTMLUnit)");
}
driver = new HtmlUnitDriver();
} else {
STAppData.setTargetBrowser("Chrome 49");
if (RUNWITHGUI) {
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);
}
}
use of org.openqa.selenium.chrome.ChromeDriver in project scout.rt by eclipse.
the class SeleniumDriver method setUpDriver.
public static WebDriver setUpDriver() {
// web-driver executable
String webdriverChromeDriver = System.getProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY);
if (StringUtility.isNullOrEmpty(webdriverChromeDriver)) {
webdriverChromeDriver = OS.isFamilyWindows() ? "/seleniumDrivers/chromedriver.exe" : "/seleniumDrivers/chromedriver";
}
File chromeDriver = new File(webdriverChromeDriver);
if (!chromeDriver.exists()) {
System.out.println("Chrome driver executable not found at path: " + chromeDriver);
URL webdriverChromeDriverResource = SeleniumDriver.class.getResource(webdriverChromeDriver);
if (webdriverChromeDriverResource != null) {
chromeDriver = new File(webdriverChromeDriverResource.getFile());
webdriverChromeDriver = chromeDriver.getAbsolutePath();
}
}
if (!StringUtility.matches(webdriverChromeDriver, ".+\\.exe", Pattern.CASE_INSENSITIVE) && chromeDriver.exists() && !chromeDriver.canExecute()) {
chromeDriver.setExecutable(true);
}
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, webdriverChromeDriver);
logProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, webdriverChromeDriver);
// log-file for web-driver
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File logFile = new File(tmpDir, "webdriver.log");
String logFilePath = logFile.getAbsolutePath();
System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, logFilePath);
logProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, logFilePath);
// set web-driver in verbose mode
System.setProperty(ChromeDriverService.CHROME_DRIVER_VERBOSE_LOG_PROPERTY, "true");
logProperty(ChromeDriverService.CHROME_DRIVER_VERBOSE_LOG_PROPERTY, "true");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
// Prepare options
ChromeOptions options = new ChromeOptions();
String chromeBinary = System.getProperty("chrome.binary");
logProperty("chrome.binary", chromeBinary);
if (StringUtility.hasText(chromeBinary)) {
options.setBinary(chromeBinary);
}
options.addArguments("--lang=en");
options.addArguments("--verbose");
options.addArguments("--disable-infobars");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
// Set logging preferences (see BrowserLogRule)
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
// TODO [7.0] BSH Remove workaround, when Chrome bug is fixed
// <WORKAROUND> https://bugs.chromium.org/p/chromedriver/issues/detail?id=1552
Map<String, String> env = new HashMap<>();
env.put("LANG", "en_US.UTF-8");
System.out.println("Using custom environment variables for driver: " + new JSONObject(env).toString(2));
RemoteWebDriver driver = new ChromeDriver(new ChromeDriverService.Builder().usingAnyFreePort().withEnvironment(// <--
env).build(), capabilities);
// RemoteWebDriver driver = new ChromeDriver(options)
// </WORKAROUND>
driver.manage().timeouts().setScriptTimeout(10000, TimeUnit.SECONDS);
// Set window size roughly to the minimal supported screen size
// (1280x1024 minus some borders for browser toolbar and windows taskbar)
// Add extra 50 pixel height, because of yellow bar "Chrome is being controlled..." which comes up since v 65.0.3325
// even tough the disable-infobars property is set - doesn't work anymore :-(
driver.manage().window().setPosition(new Point(0, 0));
driver.manage().window().setSize(new Dimension(1200, 900 + 50));
Capabilities caps = driver.getCapabilities();
System.out.println("Selenium driver configured with driver=" + driver.getClass().getName() + " browser.name=" + caps.getBrowserName() + " browser.version=" + caps.getVersion());
return driver;
}
use of org.openqa.selenium.chrome.ChromeDriver in project camunda-bpm-platform by camunda.
the class AbstractWebappUiIntegrationTest method createDriver.
@BeforeClass
public static void createDriver() {
String chromeDriverExecutable = "chromedriver";
if (System.getProperty("os.name").toLowerCase(Locale.US).indexOf("windows") > -1) {
chromeDriverExecutable += ".exe";
}
File chromeDriver = new File("target/chromedriver/" + chromeDriverExecutable);
if (!chromeDriver.exists()) {
throw new RuntimeException("chromedriver could not be located!");
}
ChromeDriverService chromeDriverService = new ChromeDriverService.Builder().withVerbose(true).usingAnyFreePort().usingDriverExecutable(chromeDriver).build();
driver = new ChromeDriver(chromeDriverService);
}
use of org.openqa.selenium.chrome.ChromeDriver in project chrome_page_performance_sqlite_java by sergueik.
the class ChromePagePerformanceUtil method getLoadTime.
public double getLoadTime(String endUrl, By by) {
WebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, flexibleWait);
driver.navigate().to(endUrl);
if (by != null) {
wait.until(ExpectedConditions.presenceOfElementLocated(by)).click();
}
waitPageToLoad(driver, wait);
setTimer(driver);
return calculateLoadTime();
}
Aggregations