List of usage examples for org.openqa.selenium WebDriver get
void get(String url);
From source file:org.mousephenotype.www.testing.model.GraphValidatorPreqc.java
License:Apache License
public PageStatus validate(WebDriver driver, GenePage genePage, GraphTestDTO geneGraph) { PageStatus status = new PageStatus(); String message;// w w w . ja v a 2s . c om List<String> urls = genePage.getGraphUrls(geneGraph.getProcedureName(), geneGraph.getParameterName()); for (String url : urls) { if (!TestUtils.isPreQcLink(url)) { logger.info("Not a preqc graph. Continuing...: Gene Page URL: " + genePage.getTarget() + ". Graph URL: " + url); continue; } // If the graph page doesn't load, log it. driver.get(url); // Make sure there is a div.viz-tools. List<WebElement> elements = driver .findElements(By.xpath("//div[@class='viz-tools' or @class='phenodcc-heatmap']")); if (elements.isEmpty()) { message = "ERROR: " + "\n\tpreQc graph[ " + geneGraph.getProcedureParameterName() + "] URL: " + url + ". Gene page: " + genePage.getTarget() + "\n[FAILED]"; status.addError(message); } } return status; }
From source file:org.mousephenotype.www.testing.model.SearchPage.java
License:Apache License
/** * Creates a new <code>SearchPage</code> instance attempting to load the * search web page at <code>target</code>. * @param driver Web driver/*from www . jav a 2 s. co m*/ * @param timeoutInSeconds The <code>WebDriver</code> timeout, in seconds * @param target target search URL * @param phenotypePipelineDAO * @param baseUrl A fully-qualified hostname and path, such as * http://ves-ebi-d0:8080/mi/impc/dev/phenotype-arcihve * @throws RuntimeException If the target cannot be set */ public SearchPage(WebDriver driver, int timeoutInSeconds, String target, PhenotypePipelineDAO phenotypePipelineDAO, String baseUrl) throws RuntimeException { this.driver = driver; this.timeoutInSeconds = timeoutInSeconds; this.phenotypePipelineDAO = phenotypePipelineDAO; this.baseUrl = baseUrl; wait = new WebDriverWait(driver, timeoutInSeconds); if ((target != null) && (!target.isEmpty())) { try { driver.get(target); } catch (Exception e) { throw new RuntimeException("EXCEPTION: " + e.getLocalizedMessage() + "\ntarget: '" + target + "'"); } this.target = target; } }
From source file:org.mozilla.zest.core.v1.ZestClientLaunch.java
License:Mozilla Public License
@Override public String invoke(ZestRuntime runtime) throws ZestClientFailException { try {/*from w ww .j av a 2s. c o m*/ WebDriver driver = null; DesiredCapabilities cap = new DesiredCapabilities(); String httpProxy = runtime.getProxy(); if (httpProxy.length() > 0) { Proxy proxy = new Proxy(); proxy.setHttpProxy(httpProxy); proxy.setSslProxy(httpProxy); cap.setCapability(CapabilityType.PROXY, proxy); } if (capabilities != null) { for (String capability : capabilities.split("\n")) { if (capability != null && capability.trim().length() > 0) { String[] typeValue = capability.split("="); if (typeValue.length != 2) { throw new ZestClientFailException(this, "Invalid capability, expected type=value : " + capability); } cap.setCapability(typeValue[0], typeValue[1]); } } } if ("Firefox".equalsIgnoreCase(this.browserType)) { driver = new FirefoxDriver(cap); } else if ("Chrome".equalsIgnoreCase(this.browserType)) { driver = new ChromeDriver(cap); } else if ("HtmlUnit".equalsIgnoreCase(this.browserType)) { driver = new HtmlUnitDriver(DesiredCapabilities.htmlUnit().merge(cap)); } else if ("InternetExplorer".equalsIgnoreCase(this.browserType)) { driver = new InternetExplorerDriver(cap); } else if ("Opera".equalsIgnoreCase(this.browserType)) { driver = new OperaDriver(cap); } else if ("PhantomJS".equalsIgnoreCase(this.browserType)) { driver = new PhantomJSDriver(cap); } else if ("Safari".equalsIgnoreCase(this.browserType)) { driver = new SafariDriver(cap); } else { // See if its a class name try { Class<?> browserClass = this.getClass().getClassLoader().loadClass(this.browserType); Constructor<?> cons = browserClass.getConstructor(Capabilities.class); if (cons != null) { driver = (WebDriver) cons.newInstance(cap); } else { throw new ZestClientFailException(this, "Unsupported browser type: " + this.getBrowserType()); } } catch (ClassNotFoundException e) { throw new ZestClientFailException(this, "Unsupported browser type: " + this.getBrowserType()); } } runtime.addWebDriver(getWindowHandle(), driver); if (this.url != null) { driver.get(runtime.replaceVariablesInString(this.url, true)); } return getWindowHandle(); } catch (Exception e) { throw new ZestClientFailException(this, e); } }
From source file:org.netbeans.modules.jackpot30.web.ui.test.OverallTest.java
License:Open Source License
@Test public void overallTest() throws Exception { // WebDriver driver = new FirefoxDriver(); WebDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_10); ((HtmlUnitDriver) driver).setJavascriptEnabled(true); try {/*from w w w . ja v a 2 s. c om*/ driver.get("http://localhost:" + System.getProperty("PORT", "9998") + "/index/ui/index.html"); //wait for the page to be rendered: new WebDriverWait(driver, 20).until(new Predicate<WebDriver>() { public boolean apply(WebDriver t) { List<WebElement> cb = t.findElements(By.id("projectCheckBox-data")); return !cb.isEmpty() && cb.get(0).isDisplayed(); } }); WebElement searchInput = driver.findElements(By.id("search-input")).get(0); searchInput.sendKeys("ClassA"); searchInput.submit(); WebElement link = new WebDriverWait(driver, 20).until(new Function<WebDriver, WebElement>() { public WebElement apply(WebDriver t) { List<WebElement> cb = t.findElements(By.tagName("a")); for (WebElement we : cb) { String href = we.getAttribute("href"); if (href != null && href.contains("goto=CLASS:org.netbeans.modules.jackpot30.example.ClassA")) return we; } return null; } }); link.click(); WebElement methodIdentifierSpan = new WebDriverWait(driver, 20) .until(new Function<WebDriver, WebElement>() { public WebElement apply(WebDriver t) { List<WebElement> cb = t.findElements(By.tagName("span")); for (WebElement we : cb) { String href = we.getAttribute("jpt30pos"); if (href != null && href.equals("88")) return we; } return null; } }); String classes = methodIdentifierSpan.getAttribute("class"); Assert.assertTrue(classes.contains("identifier") && classes.contains("method") && classes.contains("declaration") && classes.contains("public")); methodIdentifierSpan.click(); Assert.assertEquals( Arrays.asList("example/src/org/netbeans/modules/jackpot30/example/SubClassA.java", "example/src/org/netbeans/modules/jackpot30/example/UseClassA.java"), usagesList(driver)); findCheckbox(driver, "showUsages").click(); //uncheck Assert.assertEquals(Arrays.asList("example/src/org/netbeans/modules/jackpot30/example/SubClassA.java"), usagesList(driver)); findCheckbox(driver, "showUsages").click(); //check Assert.assertEquals( Arrays.asList("example/src/org/netbeans/modules/jackpot30/example/SubClassA.java", "example/src/org/netbeans/modules/jackpot30/example/UseClassA.java"), usagesList(driver)); findCheckbox(driver, "showSubtypes").click(); //uncheck Assert.assertEquals(Arrays.asList("example/src/org/netbeans/modules/jackpot30/example/UseClassA.java"), usagesList(driver)); findCheckbox(driver, "showSubtypes").click(); //uncheck Assert.assertEquals( Arrays.asList("example/src/org/netbeans/modules/jackpot30/example/SubClassA.java", "example/src/org/netbeans/modules/jackpot30/example/UseClassA.java"), usagesList(driver)); } finally { driver.quit(); } }
From source file:org.nsesa.editor.gwt.an.it.SeleniumIT.java
License:EUPL
public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get("http://localhost:8080/editor/amendment.html?documentID=1"); final String title = driver.getTitle(); new WebDriverWait(driver, 10).until(new ExpectedCondition<Boolean>() { @Override//from w w w .jav a2 s . c om public Boolean apply(WebDriver input) { return input.getTitle().toLowerCase().contains("document 1"); } }); Assert.assertEquals("Document 1 - Nsesa Editor", driver.getTitle()); driver.quit(); }
From source file:org.nuxeo.qa.webdriver.pages.users.LoginPage.java
License:Open Source License
public static LoginPage getLoginPage(WebDriver driver, String baseUrl) { try {//from w ww . j a v a2s . c om driver.get(baseUrl + "/logout"); } catch (Exception e) { // trying but ok if failing } driver.get(baseUrl); return PageFactory.initElements(driver, LoginPage.class); }
From source file:org.ocpsoft.rewrite.faces.jsession.JSessionIdTest.java
License:Apache License
private WebDriver createBrowserAndLoadPage(final boolean cookies) { // custom HtmlUnitDriver with cookies enabled or disabled WebDriver driver = new HtmlUnitDriver() { @Override/*www . j ava2s. c om*/ protected WebClient modifyWebClient(WebClient client) { client.getCookieManager().setCookiesEnabled(cookies); return client; } }; // load the page twice to get rid of jsessionid if cookies are enabled driver.get(baseUrl + "test"); driver.get(baseUrl + "test"); return driver; }
From source file:org.ocpsoft.rewrite.servlet.config.PathAndQueryTest.java
License:Apache License
@Test public void testWithQuery() throws Exception { WebDriver driver = new HtmlUnitDriver(); driver.get(baseUrl.toString() + "pathAndQuery/pathWithQuery?p1=foo&p2=bar"); assertThat(driver.getCurrentUrl()).endsWith("/resultingPath/pathWithQuery%3Fp1=foo&p2=bar"); }
From source file:org.ocpsoft.rewrite.servlet.config.PathAndQueryTest.java
License:Apache License
@Test public void testWithoutQuery() throws Exception { WebDriver driver = new HtmlUnitDriver(); driver.get(baseUrl.toString() + "pathAndQuery/pathWithoutQuery"); assertThat(driver.getCurrentUrl()).endsWith("/resultingPath/pathWithoutQuery"); }
From source file:org.ocpsoft.rewrite.servlet.config.RedirectWithAnchorTest.java
License:Apache License
@Test public void testRedirectToUrlWithAnchor() throws Exception { WebDriver driver = new HtmlUnitDriver(); driver.get(baseUrl.toString() + "do"); assertThat(driver.getCurrentUrl()).endsWith("/it#now"); }