List of usage examples for org.openqa.selenium By className
public static By className(String className)
From source file:com.ibm.watson.app.qaclassifier.selenium.HistoryIT.java
License:Open Source License
@Test public void homeToQuestionToHome() { CommonFunctions.askQuestionViaTextInput(driver, SampleQuestions.HIGH_CONFIDENCE); driver.navigate().back();//www . ja va2 s .c o m if (CommonFunctions.isMobileUI(driver) || CommonFunctions.isTabletUI(driver)) { assertTrue("Loading the home page, asking a question, and pressing back returns back to home page", driver.findElement(By.className("getting-started-mobile")).isDisplayed()); } else { assertTrue("Loading the home page, asking a question, and pressing back returns back to home page", driver.findElement(By.className("getting-started-desktop")).isDisplayed()); } }
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 www .ja v a 2 s . com*/ 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 validateMenuListHasOptions() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); // Validate that the menu list has options menuIconImg.click();/*w ww . j a v a 2s.co m*/ WebElement menuList = driver.findElement(By.className("menu-list")); List<WebElement> menuOptions = menuList.findElements(By.xpath(".//ul/li")); assertTrue("The menu list has options", menuOptions.size() > 0); }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuIT.java
License:Open Source License
@Test public void clickingOnMenuListItemShowsOverlay() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); // Validate that the menu list has options menuIconImg.click();//from w w w.j a v a2 s. co m WebElement menuList = driver.findElement(By.className("menu-list")); assertTrue("After clicking the menu icon, the menu list is visible", menuList.isDisplayed()); List<WebElement> menuOptions = menuList.findElements(By.xpath(".//ul/li")); // The first item should be home, which is hidden on Desktop, so skip it and do the second one WebElement firstMenuOption = menuOptions.get(2); String firstMenuOptionText = firstMenuOption.getText(); firstMenuOption.click(); assertTrue("Clicking on a menu option keeps the menu list open", menuList.isDisplayed()); WebElement menuOverlay = driver.findElement(By.id("menuOverlay")); WebElement menuOverlayHeading = menuOverlay.findElement(By.xpath(".//div[@class='header']/h2")); assertThat("The menu list option contains the same text as the menu overlay heading", firstMenuOptionText, is(menuOverlayHeading.getText())); WebElement menuOverlayContent = menuOverlay.findElement(By.id("menuContent")); assertTrue("The menu overlay contains some text content for the selected menu option", menuOverlayContent.getText().length() > 0); }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuIT.java
License:Open Source License
@Test public void closeMenuOverlayByClickingOnClose() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); menuIconImg.click();/*from w ww . j av a 2 s. c o m*/ WebElement menuList = driver.findElement(By.className("menu-list")); List<WebElement> menuOptions = menuList.findElements(By.xpath(".//ul/li")); // The first item should be home, which is hidden on Desktop, so skip it and do the second one WebElement firstMenuOption = menuOptions.get(2); firstMenuOption.click(); // Hit ESC closes the menu overlay WebElement menuOverlay = driver.findElement(By.id("menuOverlay")); WebElement close = menuOverlay .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' close ')]")); close.click(); assertTrue("Hitting the close button closes the menu overlay", driver.findElements(By.id("menuOverlay")).size() == 0); }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuIT.java
License:Open Source License
@Test public void closeMenuOverlayWithEscapeKey() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); menuIconImg.click();//from w w w . j a va 2 s . co m WebElement menuList = driver.findElement(By.className("menu-list")); List<WebElement> menuOptions = menuList.findElements(By.xpath(".//ul/li")); // The first item should be home, which is hidden on Desktop, so skip it and do the second one WebElement firstMenuOption = menuOptions.get(2); firstMenuOption.click(); // Press ESC to close overlay WebElement menuOverlay = driver.findElement(By.id("menuOverlay")); menuOverlay.sendKeys(Keys.ESCAPE); assertTrue("Hitting the ESC key closes the menu overlay", driver.findElements(By.id("menuOverlay")).size() == 0); }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuIT.java
License:Open Source License
@Test public void closeMenuOverlayByClickingOutsideOfContent() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); menuIconImg.click();// w w w. j a v a2 s. c o m WebElement menuList = driver.findElement(By.className("menu-list")); List<WebElement> menuOptions = menuList.findElements(By.xpath(".//ul/li")); // The first item should be home, which is hidden on Desktop, so skip it and do the second one WebElement firstMenuOption = menuOptions.get(2); firstMenuOption.click(); // Click outside of the content WebElement menuOverlay = driver.findElement(By.id("menuOverlay")); WebElement menuContent = menuOverlay.findElement(By.xpath(".//div[@id='menu']")); Actions action = new Actions(driver); action.moveToElement(menuContent, -1, -1); action.click().build().perform(); assertTrue("Clicking outside of the content closes the menu overlay", driver.findElements(By.id("menuOverlay")).size() == 0); }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuIT.java
License:Open Source License
@Test public void clickingOnMenuContentDoesNotCloseOverlay() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); menuIconImg.click();// w w w. jav a2 s .co m WebElement menuList = driver.findElement(By.className("menu-list")); List<WebElement> menuOptions = menuList.findElements(By.xpath(".//ul/li")); // The first item should be home, which is hidden on Desktop, so skip it and do the second one WebElement firstMenuOption = menuOptions.get(2); firstMenuOption.click(); // Click inside of the content WebElement menuOverlay = driver.findElement(By.id("menuOverlay")); WebElement menuContent = menuOverlay.findElement(By.xpath(".//div[@id='menu']")); Actions action = new Actions(driver); action.moveToElement(menuContent, 1, 1); action.click().build().perform(); assertTrue("Clicking inside of the content does not close the menu overlay", driver.findElements(By.id("menuOverlay")).size() == 1); }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuMobileIT.java
License:Open Source License
@Test public void clickMenuIconShowsMenuOnMobile() { WebElement menuIconImg = driver.findElement(By.className("menuIconImg")); WebElement menuList = driver.findElement(By.className("menu-list")); // Click the menu icon, it should show the menu list menuIconImg.click();/* ww w . j a va2 s. c o m*/ assertTrue("After clicking on the menu icon, the menu list is shown", menuList.isDisplayed()); }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuMobileIT.java
License:Open Source License
@Test public void clickOnMenuOptionShowsContent() { WebElement menuIconImg = driver.findElement(By.className("menuIconImg")); WebElement menuList = driver.findElement(By.className("menu-list")); WebElement menuContent = driver.findElement(By.className("menu-content")); // Click the menu icon, it should show the menu list menuIconImg.click();//from w w w . java 2 s . co m //Get list of menu options List<WebElement> menuOptions = menuList.findElements(By.xpath(".//ul/li")); WebElement firstMenuOption = menuOptions.get(2); // Get content of "About" option that has content firstMenuOption.click(); new WebDriverWait(driver, 1).until(ExpectedConditions.visibilityOf(menuContent)); assertTrue("After clicking on the menu option, the menu option content is displayed", menuContent.isDisplayed()); }