List of usage examples for org.openqa.selenium.support.ui ExpectedConditions invisibilityOfElementLocated
public static ExpectedCondition<Boolean> invisibilityOfElementLocated(final By locator)
From source file:com.hotwire.selenium.desktop.us.results.hotel.fragments.filters.HotelResultsFilteringTabsPanelFragment.java
License:Open Source License
public void doWaitForUpdatingLayer() { By locator = By.cssSelector("div[id='updatingLayer'] .loadingMask"); new WebDriverWait(getWebDriver(), DEFAULT_WAIT + 10) .until(ExpectedConditions.invisibilityOfElementLocated(locator)); }
From source file:com.hotwire.selenium.desktop.widget.DatePicker.java
License:Open Source License
public void selectDateLegacyCalendar(Date d) { //make sure we advance to the correct month before showing the calendar JavascriptExecutor jsExecutor = (JavascriptExecutor) getWebDriver(); String inputElementId = inputElement.getAttribute("id"); jsExecutor.executeScript("var cal = CompSupport.getJsObj('" + inputElementId + "'); cal.yCal.cfg.setProperty('pagedate', new Date(" + d.getTime() + ")); cal.renderRequired=true;"); inputElement.click();/*ww w. j a v a2 s.com*/ //block/wait until the calendar layer is actually visible new Wait<WebElement>(ExpectedConditions.visibilityOf(datePickerContainer)).maxWait(MAX_WAIT) .apply(getWebDriver()); Calendar cal = GregorianCalendar.getInstance(); cal.setTime(d); StringBuilder cssSelectorForAnchor = new StringBuilder(); cssSelectorForAnchor.append("#").append(datePickerContainer.getAttribute("id")).append(" "); cssSelectorForAnchor.append(".m").append(cal.get(Calendar.MONTH) + 1).append(" "); cssSelectorForAnchor.append(".d").append(cal.get(Calendar.DAY_OF_MONTH)).append(" a"); WebElement anchor = datePickerContainer.findElement(By.cssSelector(cssSelectorForAnchor.toString())); anchor.click(); //block/wait until the text is actually placed in the input field and the calendar is hidden new WebDriverWait(getWebDriver(), MAX_WAIT) .until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(CSS_CALENDAR))); }
From source file:com.hotwire.selenium.desktop.widget.DatePicker.java
License:Open Source License
public void selectDateJQueryCalendar(Date d) { //make sure we advance to the correct month before showing the calendar JavascriptExecutor jsExecutor = (JavascriptExecutor) getWebDriver(); String inputElementId = inputElement.getAttribute("id"); jsExecutor.executeScript(//from w ww .j a v a 2 s . c o m "$('#" + inputElementId + "').datepicker('setDate', new Date(" + d.getTime() + "));"); inputElement.click(); //block/wait until the calendar layer is actually visible new WebDriverWait(getWebDriver(), MAX_WAIT).until(ExpectedConditions.visibilityOf(datePickerContainer)); Calendar cal = Calendar.getInstance(); cal.setTime(d); String fmt = ".//table[@class='ui-datepicker-calendar']//td[@data-year='%d'][@data-month='%d']//a[text()='%d']"; WebElement anchor = datePickerContainer.findElement(By.xpath(String.format(fmt, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)))); anchor.click(); //block/wait until the text is actually placed in the input field and the calendar is hidden new WebDriverWait(getWebDriver(), MAX_WAIT) .until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(CSS_CALENDAR))); }
From source file:com.hotwire.selenium.desktop.widget.DatePicker.java
License:Open Source License
public void typeDate(String formattedDateString) { logger.info("Typing date: " + formattedDateString); inputElement.click();/*w ww .j a v a 2 s.co m*/ inputElement.clear(); inputElement.sendKeys(formattedDateString + Keys.ESCAPE); new WebDriverWait(getWebDriver(), MAX_WAIT) .until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(CSS_CALENDAR))); }
From source file:com.hotwire.selenium.mobile.search.HotelSearchFragment.java
License:Open Source License
public List<String> getSearchSuggestions(String destinationLocation) { List<String> searchSuggestions = new ArrayList<String>(); hotelLocation.click();/* www. j av a 2s.c o m*/ new WebDriverWait(getWebDriver(), TIME_OUT_IN_SECONDS) .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div.cloak"))); hotelLocation.clear(); hotelLocation.sendKeys(destinationLocation); new WebDriverWait(getWebDriver(), TIME_OUT_IN_SECONDS) .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("tr.ng-scope"))); for (WebElement e : getWebDriver().findElements(By.cssSelector("form[name='destinations'] td"))) { searchSuggestions.add(e.getText()); } hotelLocation.submit(); new WebDriverWait(getWebDriver(), TIME_OUT_IN_SECONDS) .until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div.cloak"))); searchSuggestions.remove(0); return searchSuggestions; }
From source file:com.hotwire.test.steps.bex.BexAbstractModel.java
License:Open Source License
public void waitPolling(String cssSelector) { new WebDriverWait(getWebdriverInstance(), MAX_WAIT) .until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(cssSelector))); }
From source file:com.htmlhifive.pitalium.sample.dialogInsideWindow.DialogInsideWindowTest.java
License:Apache License
@Test public void dialogInsideWindowTest() throws Exception { // ????????/*from ww w .j a v a2 s. com*/ 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.liferay.faces.test.Icefaces4PortletTest.java
License:Open Source License
@Test @RunAsClient/*from ww w.j av a2s .c o m*/ @InSequence(2000) public void validateEmail() throws Exception { String foo = ""; // checks an invalid email address logger.log(Level.INFO, "Entering an invalid email address 'test' ..."); emailAddressField.sendKeys("test"); phoneNumberField.click(); logger.log(Level.INFO, "Waiting for the emailAddressFieldError to contain 'Invalid e-mail address' ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(emailAddressFieldErrorXpath), "Invalid e-mail address")); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); assertTrue("emailAddressField should be visible after tabbing out with no value," + " but " + emailAddressFieldErrorXpath + " is not visible.", false); } logger.log(Level.INFO, "emailAddressField.getAttribute('value') = " + emailAddressField.getAttribute("value")); assertTrue("Invalid e-mail address validation message displayed", emailAddressFieldError.getText().contains("Invalid e-mail address")); logger.log(Level.INFO, "emailAddressFieldError.isDisplayed() = " + emailAddressFieldError.isDisplayed()); logger.log(Level.INFO, "emailAddressFieldError.getText() = " + emailAddressFieldError.getText()); // checks a valid email address logger.log(Level.INFO, "Waiting for the emailAddressFieldError to contain '' ..."); try { emailAddressField.clear(); WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(emailAddressFieldXpath), "")); logger.log(Level.INFO, "emailAddressField.getText() = '" + emailAddressField.getText() + "'"); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); if (isThere(browser, emailAddressFieldXpath)) { foo = emailAddressField.getText(); } assertTrue("emailAddressField should be clear," + " but " + emailAddressFieldXpath + " contains '" + foo + "'", false); } logger.log(Level.INFO, "Entering a valid email address 'test@liferay.com' ..."); emailAddressField.click(); emailAddressField.sendKeys("test@liferay.com"); emailAddressField.sendKeys(Keys.TAB); phoneNumberField.click(); logger.log(Level.INFO, "Waiting for the emailAddressFieldError to contain 'test@liferay.com' ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(emailAddressFieldXpath), "test@liferay.com")); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); if (isThere(browser, emailAddressFieldXpath)) { foo = emailAddressField.getText(); } assertTrue("emailAddressField should contain 'test@liferay.com'," + " but " + emailAddressFieldXpath + " contains '" + foo + "'", false); } logger.log(Level.INFO, "Waiting for the emailAddressFieldError to disappear ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(emailAddressFieldErrorXpath))); logger.log(Level.INFO, "emailAddressField.getAttribute('value') = " + emailAddressField.getAttribute("value")); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); if (isThere(browser, emailAddressFieldErrorXpath)) { foo = emailAddressFieldError.getText(); } assertTrue("emailAddressFieldError should NOT be visible after entering 'test@liferay.com'," + " but " + emailAddressFieldErrorXpath + " is still there showing '" + foo + "'", false); } }
From source file:com.liferay.faces.test.Icefaces4PortletTest.java
License:Open Source License
@Test @RunAsClient/*from w ww. j a va 2 s . c om*/ @InSequence(8000) public void dateValidation() throws Exception { String foo = ""; // checks an invalid dateOfBirth try { dateOfBirthField.clear(); logger.log(Level.INFO, "No exceptions occured when clearing the dateOfBirthField"); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); assertTrue( "No exceptions should occur when clearing the dateOfBirthField, but one did occur with the following message: " + e.getMessage(), false); } logger.log(Level.INFO, "Waiting for the dateOfBirthField to contain '' ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(dateOfBirthFieldXpath), "")); logger.log(Level.INFO, "after clearing dateOfBirthField.getAttribute('value') = " + dateOfBirthField.getAttribute("value")); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); if (isThere(browser, dateOfBirthFieldErrorXpath)) { foo = dateOfBirthFieldError.getText(); } assertTrue("dateOfBirthField should be empty after clearing," + " but " + dateOfBirthFieldXpath + " contains '" + foo + "'.", false); } logger.log(Level.INFO, "Entering an invalid value for the date of birth ... 12/34/5678 ..."); dateOfBirthField.sendKeys("12/34/5678"); logger.log(Level.INFO, "Waiting for the dateOfBirthField to contain '12/34/5678' ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(dateOfBirthFieldXpath), "12/34/5678")); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); if (isThere(browser, dateOfBirthFieldErrorXpath)) { foo = dateOfBirthFieldError.getText(); } assertTrue("dateOfBirthField should contain '12/34/5678'," + " but " + dateOfBirthFieldXpath + " contains '" + foo + "'.", false); } submitButton.click(); logger.log(Level.INFO, "Waiting for the dateOfBirthFieldError to contain 'Invalid date format' ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(dateOfBirthFieldErrorXpath), "Invalid date format")); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); assertTrue("dateOfBirthFieldError should be visible after submitting with '12/34/5678'," + " but " + dateOfBirthFieldErrorXpath + " is not visible.", false); } logger.log(Level.INFO, "dateOfBirthField.getAttribute('value') = " + dateOfBirthField.getAttribute("value")); logger.log(Level.INFO, "dateOfBirthFieldError.isDisplayed() = " + dateOfBirthFieldError.isDisplayed()); logger.log(Level.INFO, "dateOfBirthFieldError.getText() = " + dateOfBirthFieldError.getText()); assertTrue( "dateOfBirthFieldError should contain 'Invalid date format', but insteead contains '" + dateOfBirthFieldError.getText() + "'", dateOfBirthFieldError.getText().contains("Invalid date format")); // checks with no dateOfBirth dateOfBirthField.clear(); logger.log(Level.INFO, "Waiting for the dateOfBirthField to contain '' ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(dateOfBirthFieldXpath), "")); logger.log(Level.INFO, "after clearing dateOfBirthField.getAttribute('value') = " + dateOfBirthField.getAttribute("value")); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); if (isThere(browser, dateOfBirthFieldErrorXpath)) { foo = dateOfBirthFieldError.getText(); } assertTrue("dateOfBirthField should be empty after clearing," + " but " + dateOfBirthFieldXpath + " contains '" + foo + "'.", false); } phoneNumberField.click(); logger.log(Level.INFO, "Waiting for the dateOfBirthFieldError to contain 'Value is required' ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(dateOfBirthFieldErrorXpath), "Value is required")); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); assertTrue( "dateOfBirthFieldError should be visible after entering '12/34/5678' and clicking into another field," + " but " + dateOfBirthFieldErrorXpath + " does not contain 'Value is required'.", false); } logger.log(Level.INFO, "dateOfBirthField.getAttribute('value') = " + dateOfBirthField.getAttribute("value")); logger.log(Level.INFO, "dateOfBirthFieldError.isDisplayed() = " + dateOfBirthFieldError.isDisplayed()); logger.log(Level.INFO, "dateOfBirthFieldError.getText() = " + dateOfBirthFieldError.getText()); // checks a valid dateOfBirth foo = ""; dateOfBirthField.clear(); logger.log(Level.INFO, "Waiting for the dateOfBirthField to contain '' ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(dateOfBirthFieldXpath), "")); logger.log(Level.INFO, "after clearing dateOfBirthField.getAttribute('value') = " + dateOfBirthField.getAttribute("value")); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); if (isThere(browser, dateOfBirthFieldErrorXpath)) { foo = dateOfBirthFieldError.getText(); } assertTrue("dateOfBirthField should be empty after clearing," + " but " + dateOfBirthFieldXpath + " contains '" + foo + "'.", false); } logger.log(Level.INFO, "Entering a valid dateOfBirth = 01/02/3456 ..."); dateOfBirthField.sendKeys("01/02/3456"); logger.log(Level.INFO, "Clicking into the phoneNumberField ..."); phoneNumberField.click(); logger.log(Level.INFO, "Waiting for the dateOfBirthFieldError to disappear ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(dateOfBirthFieldErrorXpath))); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); if (isThere(browser, dateOfBirthFieldErrorXpath)) { foo = dateOfBirthFieldError.getText(); } assertTrue("dateOfBirthFieldError should NOT be visible after entering 01/02/3456," + " but " + dateOfBirthFieldErrorXpath + " is still there showing '" + foo + "'", false); } }
From source file:com.liferay.faces.test.selenium.browser.internal.BrowserDriverImpl.java
License:Open Source License
@Override public void waitForElementNotDisplayed(String elementXpath) { logger.info("Waiting for element {} not to be displayed.", elementXpath); waitFor(ExpectedConditions.invisibilityOfElementLocated(By.xpath(elementXpath))); logger.info("Element {} is not displayed.", elementXpath); }