
com.polonium.eclipserunner.webdriver.DriverFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of polonium-webdriver Show documentation
Show all versions of polonium-webdriver Show documentation
Polonium-Webdriver extends polonium core with paging functionality (page-object pattern),
and handles/recognizes fails made by selenium driver. This version has Polonium-Core included.
The newest version!
package com.polonium.eclipserunner.webdriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import static com.polonium.eclipserunner.webdriver.Browser.HTML_UNIT;
/**
* Create once static Driver object. Type dependent on static DEFAULT_BROWSER
* field
*
* @author Marek Serwanski
*/
public class DriverFactory {
// default browser is firefox
public static Browser[] TARGET_BROWSERS = {};
public static Browser CURRENT_BROWSER = HTML_UNIT;
public static Browser DEFAULT_BROWSER = HTML_UNIT;
private static WebDriver WEB_DRIVER;
//remember to provide servers when needed
public static WebDriver getDriver() {
if (WEB_DRIVER == null) {
switch (CURRENT_BROWSER) {
case HTML_UNIT:
WEB_DRIVER = new HtmlUnitDriver();
break;
case FIREFOX:
WEB_DRIVER = new FirefoxDriver();
break;
case IEXPLORER:
WEB_DRIVER = new InternetExplorerDriver();
break;
case CHROME:
WEB_DRIVER = new ChromeDriver();
break;
}
}
return WEB_DRIVER;
}
public static void clearDriver() {
WEB_DRIVER = null;
}
public static void setDefaultBrowser(){
TARGET_BROWSERS = new Browser[] {DEFAULT_BROWSER};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy