List of usage examples for org.openqa.selenium.support.ui ExpectedConditions visibilityOfElementLocated
public static ExpectedCondition<WebElement> visibilityOfElementLocated(final By locator)
From source file:com.hotwire.test.steps.tools.c3.purchase.C3PurchaseModel.java
License:Open Source License
public void checkConfirmationContactPhones(String phone1, String phone2) { By byPhone1 = By.xpath(".//li[contains(text(), '" + phone1 + "')]"); By byPhone2 = By.xpath(".//li[contains(text(), '" + phone2 + "')]"); new WebDriverWait(getWebdriverInstance(), 5).until(ExpectedConditions.visibilityOfElementLocated(byPhone1)); assertThat(getWebdriverInstance().findElement(byPhone1).isDisplayed()).as("Phone number isn't present") .isTrue();//from w w w. ja v a2 s . c o m assertThat(getWebdriverInstance().findElement(byPhone2).isDisplayed()).as("Phone number isn't present") .isTrue(); }
From source file:com.hotwire.test.steps.tools.c3.purchase.C3PurchaseModel.java
License:Open Source License
public void checkResultContactPhone(String phone) { By phoneLocator = By.xpath(".//div[contains(text(), '" + phone + "')]"); new WebDriverWait(getWebdriverInstance(), 5) .until(ExpectedConditions.visibilityOfElementLocated(phoneLocator)); boolean isPhoneDisplayed = getWebdriverInstance().findElement(phoneLocator).isDisplayed(); assertThat(isPhoneDisplayed).as("Phone number isn't present").isTrue(); }
From source file:com.hotwire.test.steps.tools.c3.purchase.C3PurchaseModel.java
License:Open Source License
public void checkCarAddonOnConfirmation() throws Exception { By tryAgain = By.xpath(".//div[@class='carAddOnConfirmation']//strong[contains(text(), 'Unfortunately')]"); try {/*from www . j a va 2 s. c om*/ new WebDriverWait(getWebdriverInstance(), 5) .until(ExpectedConditions.visibilityOfElementLocated(tryAgain)); getWebdriverInstance().findElement(tryAgain).isDisplayed(); throw new Exception("Car addon complete with issue. try again"); } catch (TimeoutException e) { logItinerary(); } }
From source file:com.hp.test.framework.jelly.WaitUntilElementVisibleTag.java
@Override public void doTag(XMLOutput arg0) throws MissingAttributeException, JellyTagException { logger.info("Started Execution of WaitUntilElementVisible function"); WebDriver driver = getSelenium();//from w w w. j a va 2s . c o m int loc = id.indexOf("="); String locator = id.substring(loc + 1); String bylocator = id.substring(0, loc); System.out.println("locator" + locator); System.out.println("id" + bylocator); switch (bylocator) { case "id": { try { System.out.println("Executing case id"); WebDriverWait wait = new WebDriverWait(driver, 300); WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(locator))); } catch (TimeoutException e) { System.out.println("TimeOut Exception" + "\n" + e.getMessage()); } break; } case "name": { try { System.out.println("Executing case name"); WebDriverWait wait = new WebDriverWait(driver, 300); WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.name(locator))); } catch (TimeoutException e) { System.out.println("TimeOut Exception" + "\n" + e.getMessage()); } break; } case "xpath": { try { System.out.println("Executing case xpath"); WebDriverWait wait = new WebDriverWait(driver, 300); WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(locator))); } catch (TimeoutException e) { System.out.println("TimeOut Exception" + "\n" + e.getMessage()); } break; } case "css": { try { System.out.println("identify element with CSS path and click"); WebDriverWait wait = new WebDriverWait(driver, 300); WebElement element = wait .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(locator))); } catch (TimeoutException e) { System.out.println("TimeOut Exception" + "\n" + e.getMessage()); break; } } try { Thread.sleep(5000); } catch (InterruptedException e) { } logger.info("Completed Execution of WaitUntilElementClickable function"); } }
From source file:com.hpe.nv.samples.advanced.AdvAllTestClassMethods.java
License:Apache License
public static void seleniumNavigateToPage() throws InterruptedException { if (!debug) { SpinnerStatus.getInstance().pauseThread(); System.out.print("\b"); }/* w ww . ja v a 2 s . c om*/ System.out.println("Navigating to the specified site using the Selenium WebDriver"); if (!debug) { SpinnerStatus.getInstance().resumeThread(); } // navigate to the site driver.get(siteUrl); driver.manage().timeouts().pageLoadTimeout(2000000, TimeUnit.MILLISECONDS); // wait for the specified element to display WebDriverWait wait = new WebDriverWait(driver, 60 * 2); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath))); }
From source file:com.hpe.nv.samples.basic.BasicAnalyze2Scenarios.java
License:Apache License
public static void seleniumNavigateToPage() throws InterruptedException { if (!debug) { SpinnerStatus.getInstance().pauseThread(); System.out.print("\b"); }//from ww w . j a v a2s . c om System.out.println("Navigating to the NV site using the Selenium WebDriver"); if (!debug) { SpinnerStatus.getInstance().resumeThread(); } // navigate to the site driver.get("http://www8.hp.com/us/en/software-solutions/network-virtualization/index.html"); driver.manage().timeouts().pageLoadTimeout(2000000, TimeUnit.MILLISECONDS); // wait for the element to display WebDriverWait wait = new WebDriverWait(driver, 60 * 2); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//nav//span[contains(text(), 'Get Started')]"))); }
From source file:com.hpe.nv.samples.basic.BasicAnalyze2Scenarios.java
License:Apache License
public static void seleniumGetStartedClick() throws InterruptedException { if (!debug) { SpinnerStatus.getInstance().pauseThread(); System.out.print("\b"); }/* www . j a va 2 s . c o m*/ System.out.println("Navigating to the \"Get Started Now\" page using the Selenium WebDriver"); if (!debug) { SpinnerStatus.getInstance().resumeThread(); } driver.findElement(By.xpath("//nav//span[contains(text(), 'Get Started')]")).click(); // wait for the element to display WebDriverWait wait = new WebDriverWait(driver, 60 * 2); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//*[contains(text(), 'Network Virtualization Downloads')]"))); }
From source file:com.hpe.nv.samples.basic.BasicAnalyze2Scenarios.java
License:Apache License
public static void seleniumOverviewClick() throws InterruptedException { if (!debug) { SpinnerStatus.getInstance().pauseThread(); System.out.print("\b"); }//from w w w. j a v a2 s. c o m System.out.println("Navigating to the \"Overview\" page using the Selenium WebDriver"); if (!debug) { SpinnerStatus.getInstance().resumeThread(); } driver.findElement(By.xpath("//nav//span[contains(text(), 'Overview')]")).click(); // wait for the element to display WebDriverWait wait = new WebDriverWait(driver, 60 * 2); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//*[contains(text(), 'Key Capabilities')]"))); }
From source file:com.htmlhifive.pitalium.sample.dialogInsideWindow.DialogInsideWindowTest.java
License:Apache License
@Test public void dialogInsideWindowTest() throws Exception { // ????????//from ww w . jav a 2s .c om driver.get("dialogInsideWindow"); assertionView.assertView("OpenMainWindow"); // ?????? driver.findElementById("openLoginModal").click(); // ?????? WebDriverWait wait = new WebDriverWait(driver, 30L); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("loginModal"))); // ???? assertionView.assertView("OpenLoginModal"); // ????? driver.findElementById("email").sendKeys("pitalium.sample@localhost.com"); driver.findElementById("password").sendKeys("password"); assertionView.assertView("EnterLoginParams"); // ??? driver.findElementById("login").click(); // ???????? wait.until((ExpectedConditions.invisibilityOfElementLocated(By.id("loginModal")))); assertionView.assertView("LoggedIn"); }
From source file:com.ibm.sbt.automation.core.environment.TestEnvironment.java
License:Open Source License
protected void handleOAuth10(BaseTest baseTest) { String loginFormId = baseTest.getProperty(PROP_OAUTH10_LOGINFORMID); String usernameId = baseTest.getProperty(PROP_OAUTH10_USERNAMEID); String passwordId = baseTest.getProperty(PROP_OAUTH10_PASSWORDID); String submitId = baseTest.getProperty(PROP_OAUTH10_SUBMITID); String username = baseTest.getProperty(PROP_OAUTH10_USERNAME); String password = baseTest.getProperty(PROP_OAUTH10_PASSWORD); WebElement loginForm = waitForLoginForm(loginTimeout, loginFormId, null, OAuth10LoginTitle, baseTest); if (baseTest.isResultsReady()) return;/*from www.j ava2 s.com*/ if (loginForm != null) { WebElement continueButton = loginForm.findElement(By.id("continue")); WebElement usernameEl = loginForm.findElement(By.name(usernameId)); WebElement passwordEl = loginForm.findElement(By.name(passwordId)); WebElement submitEl = loginForm.findElements(By.id(submitId)).get(0); usernameEl.sendKeys(username); if (continueButton != null) { continueButton.click(); WebDriverWait wait = new WebDriverWait(webDriver, 10); WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(submitId))); } passwordEl.sendKeys(password); submitEl.click(); } else { fail("Unable to locate OAuth1.0 login form"); } }