List of usage examples for org.openqa.selenium.firefox FirefoxDriver FirefoxDriver
public FirefoxDriver()
From source file:OnlineShopTest.BaseTest.java
@Before public void setup() { System.setProperty("webdriver.gecko.driver", "libs/geckodriver"); driver = new FirefoxDriver(); wait = new WebDriverWait(driver, 30); }
From source file:OnlineStore.StepDefinitions.java
@Given("a Firefox browser") public void openFirefox() { System.setProperty("webdriver.gecko.driver", "libs/geckodriver"); driver = new FirefoxDriver(); wait = new WebDriverWait(driver, 30); }
From source file:oop.appengine.modules.test.selenium.WebDriverFactory.java
License:Apache License
/** * ?driverName??WebDriver./*w ww. j av a 2 s . com*/ * * ??firefox,ie,chrome??. * * ??????HtmlUnit. * * ????Windows, IE?XWindows, ???remote driverWindows. * drivernameremote:192.168.0.2:4444:firefox, ??http://192.168.0.2:4444/wd/hub?selenium remote?. */ public static WebDriver createDriver(String driverName) { WebDriver driver = null; if (BrowserType.firefox.name().equals(driverName)) { driver = new FirefoxDriver(); } else if (BrowserType.ie.name().equals(driverName)) { driver = new InternetExplorerDriver(); } else if (BrowserType.chrome.name().equals(driverName)) { driver = new ChromeDriver(); } else if (BrowserType.htmlunit.name().equals(driverName)) { driver = new HtmlUnitDriver(true); } else if (driverName.startsWith(BrowserType.remote.name())) { String[] params = driverName.split(":"); Assert.isTrue(params.length == 4, "Remote driver is not right, accept format is \"remote:localhost:4444:firefox\", but the input is\"" + driverName + "\""); String remoteHost = params[1]; String remotePort = params[2]; String driverType = params[3]; String remoteUrl = "http://" + remoteHost + ":" + remotePort + "/wd/hub"; DesiredCapabilities cap = null; if (BrowserType.firefox.name().equals(driverType)) { cap = DesiredCapabilities.firefox(); } else if (BrowserType.ie.name().equals(driverType)) { cap = DesiredCapabilities.internetExplorer(); } else if (BrowserType.chrome.name().equals(driverType)) { cap = DesiredCapabilities.chrome(); } try { driver = new RemoteWebDriver(new URL(remoteUrl), cap); } catch (MalformedURLException e) { throw new RuntimeException(e); } } Assert.notNull(driver, "Driver could be found by name:" + driverName); return driver; }
From source file:org.abstractform.vaadin.itest.test.ITTestAll.java
License:Apache License
@Before public void setUp() throws Exception { driver = new FirefoxDriver(); baseUrl = "http://localhost:9988/"; driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); }
From source file:org.alfresco.AbstractTest.java
License:Open Source License
@BeforeClass public static void setup() { driver = new FirefoxDriver(); driver.navigate().to(SHARE_TEST_URL); }
From source file:org.alfresco.demo.func.HelloWorld.java
License:Open Source License
@BeforeClass public static void setup() { driver = new FirefoxDriver(); driver.get("http://localhost:8080/alfresco/service/api/login?u=admin&pw=admin"); WebElement ticket = driver.findElement(By.tagName("ticket")); String token = String.format("?alf_ticket=%s", ticket.getText()); driver.get("http://localhost:8080/alfresco/service/summit/hello" + token); }
From source file:org.alfresco.demoamp.DemoTestIT.java
License:Open Source License
@BeforeClass public static void setup() { //Create WebDriver driver = new FirefoxDriver(); //Login and obtain ticket driver.get("http://localhost:8080/alfresco/service/api/login?u=admin&pw=admin"); WebElement ticket = driver.findElement(By.tagName("ticket")); String token = String.format("?alf_ticket=%s", ticket.getText()); //Navigate to sample page with token driver.get("http://localhost:8080/alfresco/service/sample/helloworld" + token); }
From source file:org.alfresco.FetchTest.java
License:Open Source License
@BeforeClass public static void setup() { driver = new FirefoxDriver(); driver.navigate().to(AbstractTest.SHARE_TEST_URL); }
From source file:org.apache.archiva.web.test.tools.WebdriverUtility.java
License:Apache License
public static WebDriver newWebDriver(String seleniumBrowser, String seleniumHost, int seleniumPort, boolean seleniumRemote) { log.info("WebDriver {}, {}, {}, {}", seleniumBrowser, seleniumHost, seleniumPort, seleniumRemote); if (seleniumRemote && StringUtils.isEmpty(seleniumHost)) { throw new IllegalArgumentException("seleniumHost must be set, when seleniumRemote=true"); }//ww w . ja v a 2 s .c om try { if (StringUtils.contains(seleniumBrowser, "chrome")) { ChromeOptions options = new ChromeOptions(); options.addArguments("start-maximized"); if (seleniumRemote) { DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability(ChromeOptions.CAPABILITY, options); return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), capabilities); } else { return new ChromeDriver(options); } } if (StringUtils.contains(seleniumBrowser, "safari")) { if (seleniumRemote) { return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.safari()); } else { return new SafariDriver(); } } if (StringUtils.contains(seleniumBrowser, "iexplore")) { if (seleniumRemote) { return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.internetExplorer()); } else { new InternetExplorerDriver(); } } if (StringUtils.contains(seleniumBrowser, "firefox")) { if (seleniumRemote) { return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.firefox()); } else { return new FirefoxDriver(); } } DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit(); capabilities.setJavascriptEnabled(true); capabilities.setVersion("firefox-52"); WebDriver driver; if (seleniumRemote) { driver = new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), capabilities); } else { driver = new HtmlUnitDriver(capabilities) { @Override protected WebClient modifyWebClient(WebClient client) { client.getOptions().setThrowExceptionOnFailingStatusCode(false); client.getOptions().setThrowExceptionOnScriptError(false); client.getOptions().setCssEnabled(true); return client; } }; } return driver; } catch (MalformedURLException e) { throw new RuntimeException("Initializion of remote driver failed"); } }
From source file:org.apache.archiva.web.test.WebDriverBrowseTest.java
License:Apache License
@Override public WebDriver getDefaultDriver() { String seleniumBrowser = System.getProperty("selenium.browser"); if (StringUtils.contains(seleniumBrowser, "chrome")) { return new ChromeDriver(); }/*from ww w .j av a 2s .c o m*/ if (StringUtils.contains(seleniumBrowser, "safari")) { return new SafariDriver(); } if (StringUtils.contains(seleniumBrowser, "iexplore")) { return new InternetExplorerDriver(); } return new FirefoxDriver(); }