List of usage examples for org.openqa.selenium WebElement isDisplayed
boolean isDisplayed();
From source file:com.hotwire.test.steps.search.hotel.HotelSearchModelWebApp.java
License:Open Source License
@Override public void verifyMediaPlannerLayerIsShown() { new WebDriverWait(getWebdriverInstance(), 20).until( PageObjectUtils.webElementVisibleTestFunction(By.cssSelector(".HotelPlannerPopupComp"), true)); WebElement hotelPlannerLayer = getWebdriverInstance().findElement(By.cssSelector(".HotelPlannerPopupComp")); assertThat(hotelPlannerLayer.isDisplayed()).as("Expecting the hotel planner layer to be visible").isTrue(); }
From source file:com.ibm.sbt.automation.core.environment.TestEnvironment.java
License:Open Source License
/** * Dump the specified result page to the trace log *///from w ww .ja v a2 s.c om public void dumpWebElement(WebElement webElement) { Trace.log(webElement + " tagName:" + webElement.getTagName() + " text:" + webElement.getText() + " id:" + webElement.getAttribute("id") + " displayed:" + webElement.isDisplayed()); List<WebElement> webElements = webElement.findElements(By.xpath("*")); if (webElements.size() > 0) { Trace.log("Children size: " + webElements.size()); for (int i = 0; i < webElements.size(); i++) { WebElement nextElement = webElements.get(i); Trace.log("[" + i + "]" + nextElement + " tagName:" + webElement.getTagName() + " text:" + nextElement.getText() + " id:" + nextElement.getAttribute("id") + " displayed:" + nextElement.isDisplayed()); } } }
From source file:com.ibm.sbt.automation.core.test.BaseAcmeTest.java
License:Open Source License
public boolean testAcmeAirlinesSample() { //launch the sample AcmeResultPage result = launchAcmeAirlines("/index.html"); //maximize the window - Because the nav links are not visible when the browser is not maximized result.getWebDriver().manage().window().maximize(); //check the home page appears WebElement page = result.getMainContent(); assertTrue(page.isDisplayed()); boolean navigationIsOkay = checkNavigationLinks(result); assertTrue(navigationIsOkay);/*from w ww .j a v a2s .c o m*/ boolean flightsPageIsOkay = checkFlightsPage(result); assertTrue(flightsPageIsOkay); boolean myFlightsPageIsOkay = checkMyFlightsPage(result); assertTrue(myFlightsPageIsOkay); return navigationIsOkay && flightsPageIsOkay && myFlightsPageIsOkay; }
From source file:com.ibm.sbt.automation.core.test.pageobjects.VCardResultPage.java
License:Open Source License
/** * This method hovers over the card's attach point and then clicks the hover menu which appears. This should bring up the VCard. * /*from w w w .j a va2s . co m*/ * @return True if the ProfileCard appeared, false if not. */ public boolean isProfileCardDisplayable(WebElement cardAttachPoint) { WebDriver driver = getWebDriver(); new Actions(driver).moveToElement(cardAttachPoint).perform(); // hover over the attachpoint to make the semtagmenu appear. WebDriverWait wait = new WebDriverWait(driver, 5); WebElement semtagmenu = wait.until(ExpectedConditions.elementToBeClickable(By.id("semtagmenu"))); // wait until the hover menu is clickable. WebElement semTagHoverMenu = semtagmenu.findElement(By.xpath(".//a")); new Actions(driver).click(semTagHoverMenu).perform(); // click the hovering menu WebElement vCardDiv = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cardDiv"))); return vCardDiv.isDisplayed(); }
From source file:com.ibm.watson.app.qaclassifier.selenium.FeedbackScreensIT.java
License:Open Source License
@Test public void thisWasHelpfulAllowsNewInput() { CommonFunctions.askQuestionViaTextInput(driver, SampleQuestions.HIGH_CONFIDENCE); assertTrue("After asking question via text input, find answer text on answer page", CommonFunctions.getDisplayedAnswerText(driver).length() > 0); WebElement positiveFeedbackButton = driver.findElement(By.id("positiveFeedbackInput")); if (positiveFeedbackButton.isDisplayed()) { positiveFeedbackButton.click();/*from w w w . jav a 2 s . c om*/ } assertThat("After 'This was Helpful' button was pressed, thanks message is displayed", driver.findElements(By.className("thanksImage")), hasSize(1)); if (!CommonFunctions.isMobileUI(driver) && !CommonFunctions.isTabletUI(driver)) { assertThat( "After 'This was Helpful' button was pressed, text input could not be made for another question", driver.findElements(By.id("questionInputField")), hasSize(1)); assertThat( "After 'This was Helpful' button was pressed, text input could not be made for another question", driver.findElements(By.id("askButton")), hasSize(1)); } }
From source file:com.ibm.watson.app.qaclassifier.selenium.FeedbackScreensIT.java
License:Open Source License
@Test public void iStillNeedHelpShowsProperly() { CommonFunctions.askQuestionViaTextInput(driver, SampleQuestions.HIGH_CONFIDENCE); assertTrue("After asking question via text input, find answer text on answer page", CommonFunctions.getDisplayedAnswerText(driver).length() > 0); WebElement negativeFeedbackButton = driver.findElement(By.id("negativeFeedbackInput")); if (negativeFeedbackButton.isDisplayed()) { negativeFeedbackButton.click();/*www . ja va 2 s. co m*/ } assertThat("After 'I still need help' button was pressed, 'Refine my question' section is displayed", driver.findElements(By.className("refineQuestion")), hasSize(1)); assertThat("After 'I still need help' button was pressed, 'Still need help?' section is displayed", driver.findElements(By.className("stillNeedHelp")), hasSize(1)); if (!CommonFunctions.isMobileUI(driver)) { assertThat( "After 'I still need help' button was pressed, text input could not be made for another question", driver.findElements(By.id("questionInputField")), hasSize(1)); assertThat( "After 'I still need help' button was pressed, text input could not be made for another question", driver.findElements(By.id("askButton")), hasSize(1)); } }
From source file:com.ibm.watson.app.qaclassifier.selenium.FeedbackScreensIT.java
License:Open Source License
@Test public void userCanVisitForum() { CommonFunctions.askQuestionViaTextInput(driver, SampleQuestions.LOW_CONFIDENCE); WebElement noneOfTheAboveButton = CommonFunctions.findNoneOfTheAboveButton(driver); assertTrue("After asking low-confidence question, expect to find none of the above button", noneOfTheAboveButton.isDisplayed()); noneOfTheAboveButton.click();//from w w w. j av a 2 s. c o m WebElement forumButton = CommonFunctions.findVisitTheForumButton(driver); assertTrue("After clicking none of the above button, expect to find visit the forum button", forumButton.isDisplayed()); forumButton.click(); CommonFunctions.switchTabs(driver); assertThat("After clicking on the forum button, page is redirected", driver.getTitle(), is("natural-language-classifier - dWAnswers")); // Can't verify that the feedback was logged, but the log scans will catch any errors. }
From source file:com.ibm.watson.app.qaclassifier.selenium.HomePageIT.java
License:Open Source License
@Test public void askQuestionContainingOnlySpaces() { assumeFalse("Defect 106427", CommonFunctions.isMobileUI(driver) || CommonFunctions.isTabletUI(driver)); CommonFunctions.askQuestionViaTextInputExpectingError(driver, " "); WebElement errorText = driver.findElement(By.id("questionValidationError")); assertTrue("Error message was not displayed after asking an invalid question", errorText.isDisplayed()); assertThat("Incorrect error message", errorText.getText(), containsString("A question must contain at least one word")); }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuIT.java
License:Open Source License
@Test public void clickMenuIconShowsMenu() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); // Click the menu icon, it should show the menu list menuIconImg.click();/*from w w w . ja v a 2 s . c om*/ WebElement menuList = driver.findElement(By.className("menu-list")); assertTrue("After clicking on the menu icon, the menu list is shown", menuList.isDisplayed()); }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuIT.java
License:Open Source License
@Test public void clickMenuIconTwiceShowsAndHidesMenu() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); menuIconImg.click();// ww w . ja va 2 s . co m WebElement menuList = driver.findElement(By.tagName("menu-list")); assertTrue("After clicking the menu icon, the menu list is visible", menuList.isDisplayed()); // Click the menu icon again, the menu list should go away menuIconImg.click(); assertFalse("Clicking on the menu icon again closes the menu list", menuList.isDisplayed()); }