use of org.openqa.selenium.edge.EdgeDriver 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.edge.EdgeDriver in project teammates by TEAMMATES.
the class Browser method createWebDriver.
private WebDriver createWebDriver() {
System.out.print("Initializing Selenium: ");
String downloadPath;
try {
downloadPath = new File(TestProperties.TEST_DOWNLOADS_FOLDER).getCanonicalPath();
System.out.println("Download path: " + downloadPath);
} catch (IOException e) {
throw new RuntimeException(e);
}
String browser = TestProperties.BROWSER;
if (TestProperties.BROWSER_FIREFOX.equals(browser)) {
System.out.println("Using Firefox with driver path: " + TestProperties.GECKODRIVER_PATH);
String firefoxPath = TestProperties.FIREFOX_PATH;
if (!firefoxPath.isEmpty()) {
System.out.println("Custom path: " + firefoxPath);
System.setProperty("webdriver.firefox.bin", firefoxPath);
}
System.setProperty("webdriver.gecko.driver", TestProperties.GECKODRIVER_PATH);
FirefoxProfile profile = new FirefoxProfile();
// 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
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", downloadPath);
FirefoxOptions options = new FirefoxOptions().setProfile(profile);
if (TestProperties.isDevServer()) {
options.addArguments("-private");
}
return new FirefoxDriver(options);
}
if (TestProperties.BROWSER_CHROME.equals(browser)) {
System.out.println("Using Chrome with driver path: " + TestProperties.CHROMEDRIVER_PATH);
System.setProperty("webdriver.chrome.driver", TestProperties.CHROMEDRIVER_PATH);
Map<String, Object> chromePrefs = new HashMap<>();
chromePrefs.put("download.default_directory", downloadPath);
chromePrefs.put("download.prompt_for_download", false);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromePrefs);
options.addArguments("--allow-file-access-from-files");
if (TestProperties.isDevServer()) {
options.addArguments("incognito");
}
return new ChromeDriver(options);
}
if (TestProperties.BROWSER_EDGE.equals(browser)) {
System.out.println("Using Edge with driver path: " + TestProperties.EDGEDRIVER_PATH);
System.setProperty("webdriver.edge.driver", TestProperties.EDGEDRIVER_PATH);
Map<String, Object> edgePrefs = new HashMap<>();
edgePrefs.put("download.default_directory", downloadPath);
edgePrefs.put("download.prompt_for_download", false);
EdgeOptions options = new EdgeOptions();
options.setExperimentalOption("prefs", edgePrefs);
if (TestProperties.isDevServer()) {
options.addArguments("-inprivate");
}
return new EdgeDriver(options);
}
throw new RuntimeException("Using " + browser + " is not supported!");
}
use of org.openqa.selenium.edge.EdgeDriver in project chrome_page_performance_sqlite_java by sergueik.
the class ChromePagePerformanceUtil method getLoadTime.
public double getLoadTime(String endUrl) {
WebDriver driver = null;
System.setProperty(browserDriverProperties.get(browser), osName.contains("windows") ? new File(String.format("%s/%s", browserDriverPath, browserDrivers.get(browser))).getAbsolutePath() : String.format("%s/%s", browserDriverPath, browserDrivers.get(browser)));
System.err.println("browser: " + browser);
if (browser.contains("edge")) {
//
try {
driver = new EdgeDriver();
} catch (Exception e) {
System.err.println("Exception (ignord): " + e.toString());
}
} else {
driver = new ChromeDriver();
}
WebDriverWait wait = new WebDriverWait(driver, flexibleWait);
driver.navigate().to(endUrl);
waitPageToLoad(driver, wait);
setTimer(driver);
// setTimerNew(driver);
return calculateLoadTime();
}
use of org.openqa.selenium.edge.EdgeDriver in project browsermator by pcalkins.
the class RunAllTests method RunAllActions.
public void RunAllActions(SeleniumTestTool STAppFrame, SeleniumTestToolData STAppData, String TargetBrowser, String OSType) {
STAppData.TimeOfRun = LocalDateTime.now();
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 Marionette driver:" + ex.toString(), false, 0, 0);
}
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: " + ex.toString(), false, 0, 0);
}
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) {
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch IEdriver:" + ex.toString(), false, 0, 0);
}
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) {
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch IEdriver: " + ex.toString(), false, 0, 0);
}
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." + ex.toString(), false, 0, 0);
}
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." + ex.toString(), false, 0, 0);
}
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. " + ex.toString(), false, 0, 0);
}
break;
}
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;
int thisbugindex = 0;
for (Procedure thisbug : STAppData.BugArray) {
String bugtitle = STAppData.BugArray.get(thisbugindex).getBugTitle();
if (RUNWITHGUI) {
LoudCall<Void, String> procMethod = new LoudCall<Void, String>() {
@Override
public Void call() throws Exception {
shoutOut(bugtitle);
Thread.sleep(100);
return null;
}
};
(new ListenerTask<Void, String>(procMethod) {
@Override
protected void process(List<String> chunks) {
STAppFrame.setJTextFieldProgress(chunks.get(chunks.size() - 1));
}
}).execute();
STAppFrame.BugViewArray.get(thisbugindex).JButtonRunTest.setText("Running...");
}
int bug_INT = thisbugindex + 1;
String bug_ID = Integer.toString(bug_INT);
int action_INT = 0;
String action_ID = "";
if (!"Dataloop".equals(thisbug.Type)) {
action_INT = 0;
for (Action ThisAction : thisbug.ActionsList) {
if (STAppData.cancelled) {
publish(thisbugindex);
break;
}
waitWhenPaused();
action_INT++;
action_ID = Integer.toString(action_INT);
if (!ThisAction.Locked) {
if (RUNWITHGUI) {
String action_title = ThisAction.Type + ": " + ThisAction.Variable1 + " " + ThisAction.Variable2;
LoudCall<Void, String> actMethod = new LoudCall<Void, String>() {
@Override
public Void call() throws Exception {
shoutOut(action_title);
Thread.sleep(100);
return null;
}
};
(new ListenerTask<Void, String>(actMethod) {
@Override
protected void process(List<String> chunks) {
if (chunks.size() > 0) {
STAppFrame.setJTextFieldProgress(chunks.get(chunks.size() - 1));
}
}
}).execute();
}
if (totalpause > 0) {
try {
Thread.sleep(totalpause);
} catch (Exception ex) {
System.out.println("Exception when sleeping: " + ex.toString());
ThisAction.Pass = false;
if (RUNWITHGUI) {
ProcedureView thisbugview = STAppFrame.BugViewArray.get(thisbugindex);
thisbugview.ActionsViewList.get(ThisAction.index).setPassState(ThisAction.Pass);
publish(thisbugindex);
}
break;
}
}
String varfieldname = "";
if (ThisAction.Variable2.contains("[stored_varname-start]") || ThisAction.Variable1.contains("[stored_varname-start]")) {
if (ThisAction.Variable2.contains("[stored_varname-start]")) {
varfieldname = ThisAction.Variable1;
// indexof_end_tag = varfieldname.indexOf("[stored_varname_end]")-1;
// assuming name of "[stored_varname-start]" and "[stored_varname-end]"
String[] split_testfield_end = varfieldname.split("\\[stored_varname\\-end\\]");
String fieldname = split_testfield_end[0].substring(22);
ThisAction.Variable2 = STAppData.GetStoredVariableValue(fieldname);
ThisAction.RunAction(driver);
ThisAction.Variable2 = "[stored_varname-start]" + fieldname + "[stored_varname-end]";
} else {
if (ThisAction.Variable1.contains("[stored_varname-start]")) {
varfieldname = ThisAction.Variable1;
// indexof_end_tag = varfieldname.indexOf("[stored_varname_end]")-1;
// assuming name of "[stored_varname-start]" and "[stored_varname-end]"
String[] split_testfield_end = varfieldname.split("\\[stored_varname\\-end\\]");
String fieldname = split_testfield_end[0].substring(22);
ThisAction.Variable1 = STAppData.GetStoredVariableValue(fieldname);
ThisAction.RunAction(driver);
ThisAction.Variable1 = "[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 (RUNWITHGUI) {
ProcedureView thisbugview = STAppFrame.BugViewArray.get(thisbugindex);
thisbugview.ActionsViewList.get(ThisAction.index).setPassState(ThisAction.Pass);
}
}
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);
}
if (STAppData.getIncludeScreenshots()) {
try {
File full_scrn = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
full_scrn.deleteOnExit();
ThisAction.ScreenshotBase64 = "<img src=\"file:///" + full_scrn.getAbsolutePath() + "\" id = \"Screenshot" + bug_ID + "-" + action_ID + "\" style = \"display: none;\" class = \"report_screenshots\"></img>";
} catch (Exception ex) {
ThisAction.ScreenshotBase64 = "Screenshot Failed";
// System.out.println("Exception creating screenshot: " + ex.toString());
}
} else {
ThisAction.ScreenshotBase64 = "";
}
} else {
ThisAction.ScreenshotBase64 = "";
ThisAction.Pass = true;
}
if (RUNWITHGUI) {
ProcedureView thisbugview = STAppFrame.BugViewArray.get(thisbugindex);
thisbugview.ActionsViewList.get(ThisAction.index).setPassState(ThisAction.Pass);
}
}
int actionspassed = 0;
for (Action thisaction : thisbug.ActionsList) {
Boolean passvalue = thisaction.Pass;
if (passvalue) {
actionspassed++;
}
}
int sizeof = thisbug.ActionsList.size();
if (actionspassed == sizeof) {
thisbug.Pass = true;
} else {
thisbug.Pass = false;
}
} else {
int number_of_rows = 0;
if ("urllist".equals(thisbug.DataLoopSource)) {
if (thisbug.getLimit() > 0 || thisbug.getRandom()) {
thisbug.setURListRunTimeData(STAppData.RandomizeAndLimitURLList(thisbug.URLListName, thisbug.getLimit(), thisbug.getRandom()), thisbug.URLListName);
} else {
thisbug.setURListRunTimeData(STAppData.VarLists.get(thisbug.URLListName), thisbug.URLListName);
}
number_of_rows = thisbug.URLListRunTimeEntries.size();
if (RUNWITHGUI) {
if (number_of_rows > 0) {
ProcedureView thisbugview = STAppFrame.BugViewArray.get(thisbugindex);
thisbugview.setJTableSourceToURLList(thisbug.URLListRunTimeEntries, thisbug.URLListName);
}
}
} else {
if ("file".equals(thisbug.DataLoopSource)) {
if (thisbug.getLimit() > 0 || thisbug.getRandom()) {
if (STAppData.getDataSetByFileName(thisbug.DataFile).size() > 0) {
List<String[]> randomList = STAppData.RandomizeAndLimitFileList(STAppData.getDataSetByFileName(thisbug.DataFile), thisbug.getLimit(), thisbug.getRandom());
thisbug.setRunTimeFileSet(randomList);
}
} else {
thisbug.setRunTimeFileSet(STAppData.getDataSetByFileName(thisbug.DataFile));
}
number_of_rows = thisbug.RunTimeFileSet.size();
}
}
for (Action ThisAction : thisbug.ActionsList) {
ThisAction.InitializeLoopTestVars(number_of_rows);
}
for (int x = 0; x < number_of_rows; x++) {
int changex = -1;
action_INT = 0;
for (Action ThisAction : thisbug.ActionsList) {
if (STAppData.cancelled) {
publish(thisbugindex);
break;
}
waitWhenPaused();
action_INT++;
action_ID = Integer.toString(action_INT) + "-" + Integer.toString(x);
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);
ThisAction.loop_pass_values.set(x, ThisAction.Pass);
ThisAction.loop_time_of_test.set(x, ThisAction.TimeOfTest);
if (STAppData.getIncludeScreenshots()) {
ThisAction.loop_ScreenshotsBase64.set(x, "<img id = \"Screenshot" + bug_ID + "-" + action_ID + "\" class = \"report_screenshots\" style = \"display: none;\" src=\"\"></img>");
} else {
ThisAction.loop_ScreenshotsBase64.set(x, "");
}
} else {
try {
if (totalpause > 0) {
try {
Thread.sleep(totalpause);
} catch (Exception ex) {
System.out.println("Exception when sleeping: " + ex.toString());
ThisAction.Pass = false;
publish(thisbugindex);
if (RUNWITHGUI) {
ProcedureView thisbugview = STAppFrame.BugViewArray.get(thisbugindex);
thisbugview.ActionsViewList.get(ThisAction.index).setPassState(ThisAction.Pass);
}
break;
}
}
String varfieldname = "";
if (ThisAction.Variable2.contains("[stored_varname-start]") || ThisAction.Variable1.contains("[stored_varname-start]")) {
if (ThisAction.Variable2.contains("[stored_varname-start]")) {
varfieldname = ThisAction.Variable1;
// indexof_end_tag = varfieldname.indexOf("[stored_varname_end]")-1;
// assuming name of "[stored_varname-start]" and "[stored_varname-end]"
String[] split_testfield_end = varfieldname.split("\\[stored_varname\\-end\\]");
String fieldname = split_testfield_end[0].substring(22);
ThisAction.Variable2 = STAppData.GetStoredVariableValue(fieldname);
String action_title3 = ThisAction.Type + ": " + ThisAction.Variable1 + " " + ThisAction.Variable2;
if (RUNWITHGUI) {
LoudCall<Void, String> actMethod = new LoudCall<Void, String>() {
@Override
public Void call() throws Exception {
shoutOut(action_title3);
Thread.sleep(100);
return null;
}
};
(new ListenerTask<Void, String>(actMethod) {
@Override
protected void process(List<String> chunks) {
if (chunks.size() > 0) {
STAppFrame.setJTextFieldProgress(chunks.get(chunks.size() - 1));
}
}
}).execute();
}
ThisAction.RunAction(driver);
ThisAction.Variable2 = "[stored_varname-start]" + fieldname + "[stored_varname-end]";
} else {
if (ThisAction.Variable1.contains("[stored_varname-start]")) {
varfieldname = ThisAction.Variable1;
// indexof_end_tag = varfieldname.indexOf("[stored_varname_end]")-1;
// assuming name of "[stored_varname-start]" and "[stored_varname-end]"
String[] split_testfield_end = varfieldname.split("\\[stored_varname\\-end\\]");
String fieldname = split_testfield_end[0].substring(22);
ThisAction.Variable1 = STAppData.GetStoredVariableValue(fieldname);
if (RUNWITHGUI) {
String action_title2 = ThisAction.Type + ": " + ThisAction.Variable1 + " " + ThisAction.Variable2;
LoudCall<Void, String> actMethod = new LoudCall<Void, String>() {
@Override
public Void call() throws Exception {
shoutOut(action_title2);
Thread.sleep(100);
return null;
}
};
(new ListenerTask<Void, String>(actMethod) {
@Override
protected void process(List<String> chunks) {
if (chunks.size() > 0) {
STAppFrame.setJTextFieldProgress(chunks.get(chunks.size() - 1));
}
}
}).execute();
}
ThisAction.RunAction(driver);
ThisAction.Variable1 = "[stored_varname-start]" + fieldname + "[stored_varname-end]";
}
}
} else {
if (RUNWITHGUI) {
String action_title = ThisAction.Type + ": " + ThisAction.Variable1 + " " + ThisAction.Variable2;
LoudCall<Void, String> actMethod = new LoudCall<Void, String>() {
@Override
public Void call() throws Exception {
shoutOut(action_title);
Thread.sleep(100);
return null;
}
};
(new ListenerTask<Void, String>(actMethod) {
@Override
protected void process(List<String> chunks) {
if (chunks.size() > 0) {
STAppFrame.setJTextFieldProgress(chunks.get(chunks.size() - 1));
}
}
}).execute();
}
ThisAction.RunAction(driver);
}
if (!"".equals(ThisAction.tostore_varvalue)) {
STAppData.VarHashMap.put(ThisAction.tostore_varname, ThisAction.tostore_varvalue);
}
ThisAction.loop_pass_values.set(x, ThisAction.Pass);
ThisAction.loop_time_of_test.set(x, ThisAction.TimeOfTest);
} catch (Exception ex) {
ThisAction.loop_pass_values.set(x, false);
ThisAction.loop_time_of_test.set(x, LocalDateTime.now());
if (RUNWITHGUI) {
publish(thisbugindex);
ProcedureView thisbugview = STAppFrame.BugViewArray.get(thisbugindex);
thisbugview.ActionsViewList.get(ThisAction.index).setPassState(ThisAction.loop_pass_values.get(x));
}
break;
}
if (STAppData.getIncludeScreenshots()) {
try {
File full_scrn = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
full_scrn.deleteOnExit();
ThisAction.loop_ScreenshotsBase64.set(x, "<img src=\"file:///" + full_scrn.getAbsolutePath() + "\" id = \"Screenshot" + bug_ID + "-" + action_ID + "\" style = \"display: none;\" class = \"report_screenshots\"></img>");
} catch (Exception ex) {
ThisAction.loop_ScreenshotsBase64.set(x, "Screenshot Failed");
// System.out.println("Exception creating screenshot: " + ex.toString());
}
} else {
ThisAction.loop_ScreenshotsBase64.set(x, "");
}
}
} else {
String concat_variable = "";
String concat_variable2 = "";
if ("urllist".equals(thisbug.DataLoopSource)) {
concat_variable = var1Parser.GetFullValueFromURLList(x, thisbug.URLListRunTimeEntries);
}
if ("file".equals(thisbug.DataLoopSource)) {
concat_variable = var1Parser.GetFullValueFromFile(x, thisbug.RunTimeFileSet);
}
if (var1Parser.hasDataLoopVar) {
ThisAction.Variable1 = concat_variable;
if ("".equals(ThisAction.Variable1)) {
ThisAction.Variable1 = " ";
}
}
if ("urllist".equals(thisbug.DataLoopSource)) {
concat_variable2 = var2Parser.GetFullValueFromURLList(x, thisbug.URLListRunTimeEntries);
}
if ("file".equals(thisbug.DataLoopSource)) {
concat_variable2 = var2Parser.GetFullValueFromFile(x, thisbug.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;
if (RUNWITHGUI) {
publish(thisbugindex);
ProcedureView thisbugview = STAppFrame.BugViewArray.get(thisbugindex);
thisbugview.ActionsViewList.get(ThisAction.index).setPassState(ThisAction.loop_pass_values.get(x));
}
break;
}
}
if (RUNWITHGUI) {
String action_title = ThisAction.Type + ": " + ThisAction.Variable1 + " " + ThisAction.Variable2;
LoudCall<Void, String> actMethod = new LoudCall<Void, String>() {
@Override
public Void call() throws Exception {
shoutOut(action_title);
Thread.sleep(100);
return null;
}
};
(new ListenerTask<Void, String>(actMethod) {
@Override
protected void process(List<String> chunks) {
if (chunks.size() > 0) {
STAppFrame.setJTextFieldProgress(chunks.get(chunks.size() - 1));
}
}
}).execute();
}
ThisAction.RunAction(driver);
ThisAction.Variable1 = original_value1;
ThisAction.Variable2 = original_value2;
ThisAction.loop_pass_values.set(x, ThisAction.Pass);
ThisAction.loop_time_of_test.set(x, ThisAction.TimeOfTest);
if (STAppData.getIncludeScreenshots()) {
try {
File full_scrn = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
full_scrn.deleteOnExit();
ThisAction.loop_ScreenshotsBase64.set(x, "<img src=\"file:///" + full_scrn.getAbsolutePath() + "\" id = \"Screenshot" + bug_ID + "-" + action_ID + "\" style = \"display: none;\" class = \"report_screenshots\"></img>");
} catch (Exception ex) {
ThisAction.loop_ScreenshotsBase64.set(x, "Screenshot Failed");
// System.out.println("Exception creating screenshot: " + ex.toString());
}
} else {
ThisAction.loop_ScreenshotsBase64.set(x, "");
}
} catch (Exception ex) {
ThisAction.Variable1 = original_value1;
ThisAction.Variable2 = original_value2;
ThisAction.loop_pass_values.set(x, false);
ThisAction.loop_time_of_test.set(x, LocalDateTime.now());
if (RUNWITHGUI) {
ProcedureView thisbugview = STAppFrame.BugViewArray.get(thisbugindex);
thisbugview.ActionsViewList.get(ThisAction.index).setPassState(ThisAction.loop_pass_values.get(x));
publish(thisbugindex);
}
break;
}
}
} else {
ThisAction.Pass = true;
ThisAction.loop_pass_values.set(x, ThisAction.Pass);
ThisAction.loop_time_of_test.set(x, ThisAction.TimeOfTest);
}
if (RUNWITHGUI) {
ProcedureView thisbugview = STAppFrame.BugViewArray.get(thisbugindex);
thisbugview.ActionsViewList.get(ThisAction.index).setPassState(ThisAction.loop_pass_values.get(x));
}
}
if (changex != x) {
if (changex == -1) {
} else {
x = changex - 1;
}
}
}
// check if all actions passed
int actions_passed = 0;
for (Action ThisAction : thisbug.ActionsList) {
ThisAction.Pass = false;
int loop_actions_passed = 0;
if (ThisAction.loop_pass_values.size() > 0) {
for (Boolean passvalue : ThisAction.loop_pass_values) {
if (passvalue) {
loop_actions_passed++;
}
}
}
if (loop_actions_passed == ThisAction.loop_pass_values.size()) {
ThisAction.Pass = true;
}
if (ThisAction.Pass) {
actions_passed++;
}
}
int sizeof = thisbug.ActionsList.size();
if (actions_passed == sizeof) {
thisbug.Pass = true;
} else {
thisbug.Pass = false;
}
}
publish(thisbugindex);
thisbugindex++;
}
if (STAppData.getPromptToClose() && driver != null) {
PromptToClose thisContinuePrompt = new PromptToClose(STAppData.short_filename + " - Prompt to close webdriver", "Close webdriver/browser?");
thisContinuePrompt.addjButtonRunAgainActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
RunAgain = true;
thisContinuePrompt.dispose();
boolean closecaught = false;
try {
if (driver != null) {
driver.close();
}
} catch (Exception e) {
closecaught = true;
System.out.println(e.toString());
try {
driver.quit();
} catch (Exception exce) {
System.out.println("Exception quitting" + exce.toString());
}
}
if (closecaught) {
} else {
try {
driver.quit();
} catch (Exception ex) {
// don't worry it should close
}
}
}
});
thisContinuePrompt.addjButtonCloseActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
RunAgain = false;
thisContinuePrompt.dispose();
}
});
while (thisContinuePrompt.isVisible() == true) {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
System.out.println("pause exception: " + e.toString());
}
}
if (RunAgain) {
RunAllActions(STAppFrame, STAppData, targetbrowser, OSType);
}
}
}
use of org.openqa.selenium.edge.EdgeDriver in project selenified by Coveros.
the class TestSetup method setupDriver.
/**
* this creates the webdriver object, which will be used to interact with
* for all browser web tests
*
* @param browser - what browser is being tested on
* @param capabilities - what capabilities are being tested with
* @return WebDriver: the driver to interact with for the test
* @throws InvalidBrowserException If a browser that is not one specified in the
* Selenium.Browser class is used, this exception will be thrown
*/
public static WebDriver setupDriver(Browser browser, DesiredCapabilities capabilities) throws InvalidBrowserException {
WebDriver driver;
// check the browser
switch(browser) {
case HTMLUNIT:
capabilities.setBrowserName("htmlunit");
capabilities.setJavascriptEnabled(true);
System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog", "fatal");
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
java.util.logging.Logger.getLogger("org.apache.http").setLevel(Level.OFF);
driver = new HtmlUnitDriver(capabilities);
break;
case FIREFOX:
FirefoxDriverManager.getInstance().forceCache().setup();
FirefoxOptions firefoxOptions = new FirefoxOptions(capabilities);
if (System.getProperty(HEADLESS_INPUT) != null && "true".equals(System.getProperty(HEADLESS_INPUT))) {
firefoxOptions.setHeadless(true);
}
driver = new FirefoxDriver(firefoxOptions);
break;
case CHROME:
ChromeDriverManager.getInstance().forceCache().setup();
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions = chromeOptions.merge(capabilities);
if (System.getProperty(HEADLESS_INPUT) != null && "true".equals(System.getProperty(HEADLESS_INPUT))) {
chromeOptions.setHeadless(true);
}
driver = new ChromeDriver(chromeOptions);
break;
case INTERNETEXPLORER:
InternetExplorerDriverManager.getInstance().forceCache().setup();
InternetExplorerOptions internetExplorerOptions = new InternetExplorerOptions(capabilities);
driver = new InternetExplorerDriver(internetExplorerOptions);
break;
case EDGE:
EdgeDriverManager.getInstance().forceCache().setup();
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions = edgeOptions.merge(capabilities);
driver = new EdgeDriver(edgeOptions);
break;
case SAFARI:
SafariOptions safariOptions = new SafariOptions(capabilities);
driver = new SafariDriver(safariOptions);
break;
case OPERA:
OperaDriverManager.getInstance().forceCache().setup();
driver = new OperaDriver(capabilities);
break;
case PHANTOMJS:
PhantomJsDriverManager.getInstance().forceCache().setup();
driver = new PhantomJSDriver(capabilities);
break;
// if the browser is not listed, throw an error
default:
throw new InvalidBrowserException("The selected browser " + browser + " is not an applicable choice");
}
return driver;
}
Aggregations