List of usage examples for org.openqa.selenium WebDriver navigate
Navigation navigate();
From source file:io.fabric8.selenium.WebDriverFacade.java
License:Apache License
/** * Navigates to the given service name in the current namespace * * @return the URL navigated to//from www.j a va 2 s . com */ public String navigateToService(String serviceName) { String url = getServiceUrl(serviceName); WebDriver driver = getDriver(); driver.navigate().to(url); return url; }
From source file:io.github.mmichaelis.selenium.client.provider.AbstractWebDriverProvider.java
License:Apache License
/** * <p>//from ww w .ja v a 2 s . c o m * Returns to the initial page the browser has been started with. If the browser has not been started yet, it will * be started. * </p> */ private void goHome() { final WebDriverInformation driverInformation = WEB_DRIVER_INFORMATION_THREAD_LOCAL.get(); final WebDriver driver = driverInformation.getDriver(); final String initialUrl = driverInformation.getInitialUrl(); LOG.info("Going back to URL: {}", initialUrl); driver.navigate().to(initialUrl); }
From source file:io.github.siscultural.system_tests.CompleteLoginAndTryBackAndDoLoginAgain.java
@Test public void CompleteLoginAndTryBackAndDoLoginAgain() { WebDriver driver = new FirefoxDriver(); driver.get("http://localhost:8080/"); driver.findElement(By.name("email")).sendKeys("victor.hugo.origins@gmail.com"); driver.findElement(By.name("password")).sendKeys("abacaxi"); new WebDriverWait(driver, 500) { };// w w w . jav a 2 s . co m driver.findElement(By.id("input-login")).click(); new WebDriverWait(driver, 500) { }; new WebDriverWait(driver, 500) { }; driver.navigate().to("http://localhost:8080/"); Assert.assertEquals("http://localhost:8080/home", driver.getCurrentUrl()); driver.close(); }
From source file:io.selendroid.demo.webui.EmployeeDirectoryTest.java
License:Apache License
@Step("Verify the reportees of employee with id <id> are <reportees>") public void verifyNumberOfDirectReports(String id, Table reportees) throws Exception { WebDriver driver = Driver.webDriver; List<TableRow> tableRows = reportees.getTableRows(); for (int i = 0; i < tableRows.size(); i++) { Assert.assertThat(driver.findElements(By.tagName("li")).get(i).getText(), startsWith(tableRows.get(i).getCell("name"))); }/*from w ww . ja v a 2 s .com*/ driver.navigate().back(); Assert.assertEquals(driver.getCurrentUrl(), "file:///android_asset/www/index.html#employees/4"); }
From source file:iTests.framework.utils.WebuiTestUtils.java
private void waitForServerConnection(WebDriver driver) throws InterruptedException { int seconds = 0; while (seconds < 40) { try {/*from www .j av a 2 s. c om*/ driver.findElement(By.xpath(WebConstants.Xpath.loginButton)); LogUtils.log("Web server connection established"); break; } catch (NoSuchElementException e) { LogUtils.log("Unable to connect to Web server, retrying...Attempt number " + (seconds + 1)); driver.navigate().refresh(); Thread.sleep(1000); seconds++; } } if (seconds == 30) { LogUtils.log("Could not establish a connection to webui server, Test will fail"); } }
From source file:IWDmainsiteProject.PageObjects.Verify_Pages.java
public static void Verify_Button_SEETHEIRPROJECT_Work_With_A_Team(WebDriver driver) { driver.findElement(By.cssSelector("a[href*='/marucci-sporting-goods']")).click(); String actualTitle = driver.getTitle(); System.out.println(actualTitle); String expectedTitle = "Baton Rouge Louisiana Magento eCommerce Development by IWD"; assertEquals(expectedTitle, actualTitle); driver.navigate().back(); System.out.println("Title is correct"); }
From source file:limmen.hw4.view.GoogleSearchTest.java
public static void main(String... args) { WebDriver driver = new FirefoxDriver(); driver.navigate().to("http://google.com"); String appTitle = driver.getTitle(); System.out.println("Application title is :: " + appTitle); driver.quit();//from w w w . j a va2s.c o m }
From source file:main.java.qa.android.util.WaitTool.java
License:Open Source License
/** * Wait for an element to appear on the refreshed web-page. * And returns the first WebElement using the given method. */*from www .j a va2 s. c om*/ * This method is to deal with dynamic pages. * * Some sites I (Mark) have tested have required a page refresh to add additional elements to the DOM. * Generally you (Chon) wouldn't need to do this in a typical AJAX scenario. * * @param WebDriver The driver object to use to perform this element search * @param locator selector to find the element * @param int The time in seconds to wait until returning a failure * * @return WebElement the first WebElement using the given method, or null(if the timeout is reached) * * @author Mark Collin */ public static WebElement waitForElementRefresh(WebDriver driver, final By by, int timeOutInSeconds) { WebElement element; try { driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); //nullify implicitlyWait() new WebDriverWait(driver, timeOutInSeconds) { }.until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver driverObject) { driverObject.navigate().refresh(); //refresh the page **************** return isElementPresentAndDisplay(driverObject, by); } }); element = driver.findElement(by); driver.manage().timeouts().implicitlyWait(DEFAULT_WAIT_4_PAGE, TimeUnit.SECONDS); //reset implicitlyWait return element; //return the element } catch (Exception e) { Log.info(e.getMessage()); } return null; }
From source file:net.osgiliath.messaging.repository.impl.itests.ITHelloWebUITest.java
License:Apache License
@Test public void testSayHello() throws Exception { final WebDriver driver; driver = new FirefoxDriver(); // Sleep until the elements we want is visible or 5 seconds is over long end = System.currentTimeMillis() + 10000; (new WebDriverWait(driver, 300)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { driver.get("http://localhost:8181/net.osgiliath.hello.ui"); boolean ret = d.getTitle().toLowerCase().startsWith("hello"); if (!ret) { driver.navigate().refresh(); }//from w w w .ja va 2s . c o m return ret; } }); WebElement element; element = driver.findElement(By.id("helloInput")); element.click(); element.sendKeys(CORRECT_NAME); element = driver.findElement(By.id("helloButton")); element.click(); (new WebDriverWait(driver, 20)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { Collection<WebElement> cells = d.findElements(By.xpath("//table//tr//td")); return cells.size() == 1; } }); end = System.currentTimeMillis() + 10000; driver.close(); }
From source file:okw.gui.adapter.selenium.SeURL.java
License:Open Source License
public void TypeKey(ArrayList<String> fps_Values) { MyLogger.LogFunctionStartDebug("TypeKey", "fps_Values", fps_Values.get(0)); try {//from w ww . j a va2s . co m WebDriver myDriver = SeDriver.getInstance().driver; myDriver.navigate().to(fps_Values.get(0)); } finally { MyLogger.LogFunctionEndDebug(); } return; }