List of usage examples for org.openqa.selenium.support.ui ExpectedConditions visibilityOfAllElementsLocatedBy
public static ExpectedCondition<List<WebElement>> visibilityOfAllElementsLocatedBy(final By locator)
From source file:com.hotwire.selenium.desktop.us.search.MultiVerticalFareFinder.java
License:Open Source License
public HotelSearchFragment chooseHotel() { new WebDriverWait(getWebDriver(), WAIT_TIMEOUT) .until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector(HOTEL_RADIO))); getWebDriver().findElement(By.cssSelector(HOTEL_RADIO)).click(); return new HotelSearchFragment(getWebDriver()); }
From source file:com.java.AppTestType_18_11_2015.java
public void SIGNIN(WebDriver driver, String fieldText, String value) { try {/*from w w w.j av a 2 s .co m*/ try { WebDriverWait wait = new WebDriverWait(driver, 20); // wait.until(ExpectedConditions.titleIs("Used Equipment Sales | Buy & Sell Online | Ritchie Bros. EquipmentOne")); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.manage().deleteAllCookies(); //driver.findElement(By.linkText("Sign In")).click(); driver.findElement(By.name("josso_username")).clear(); driver.findElement(By.name("josso_username")).sendKeys(fieldText); driver.findElement(By.name("josso_password")).clear(); driver.findElement(By.name("josso_password")).sendKeys("Equipment1$"); try { driver.findElement(By.xpath("//*[@value='SIGN IN']")).click(); } catch (Exception elementnotfoundexException) { driver.findElement(By.xpath("//button[text()='SIGN IN']")).click(); } System.out.println("size is :" + driver.findElements(By.id("iduser")).size()); if (driver.findElements(By.id("iduser")).size() > 0) { System.out.println("1111111111"); driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS); if (driver.findElements(By.xpath("//input[@id='useragreetoterms' and @type='checkbox']")) .size() > 0) { driver.findElement(By.xpath("//input[@id='useragreetoterms' and @type='checkbox']")) .click(); driver.findElement( By.xpath("//*[@class='btn btn-primary btn-group-justified' and @type='submit']")) .click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); // driver.findElement(By.xpath("//input[@value='Go to EquipmentOne']")).click(); // wait.until(ExpectedConditions.titleIs("Used Equipment Sales | Buy & Sell Online | Ritchie Bros. EquipmentOne")); } //to confirm successful sign in as valid user,verifying the name displayed next to "Hello" text if (driver.findElement(By.id("iduser")).getText().equalsIgnoreCase(value)) System.out.println("Successfully Logged in"); else { driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.linkText("Sign Out")).click(); wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.name("josso_password"))); driver.findElement(By.name("josso_username")).clear(); driver.findElement(By.name("josso_username")).sendKeys(fieldText); driver.findElement(By.name("josso_password")).clear(); driver.findElement(By.name("josso_password")).sendKeys("Equipment1$"); driver.findElement(By.xpath("//*[@value='SIGN IN']")).click(); wait.until(ExpectedConditions.elementToBeClickable(By.id("iduser"))); //agree terms-This piece of code is to verify agree terms checkbox after re logging(not logged in as the valid user) driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS); if (driver.findElements(By.xpath("//input[@id='useragreetoterms' and @type='checkbox']")) .size() > 0) { driver.findElement(By.xpath("//input[@id='useragreetoterms' and @type='checkbox']")) .click(); driver.findElement(By .xpath("//*[@class='btn btn-primary btn-group-justified' and @type='submit']")) .click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); // driver.findElement(By.xpath("//input[@value='Go to EquipmentOne']")).click(); // wait.until(ExpectedConditions.titleIs("Used Equipment Sales | Buy & Sell Online | Ritchie Bros. EquipmentOne")); } } resultDetails.setFlag(true); } } //This catch is used to catch the error "You are NOT authorized to access Site" in E1 Login// ///////////////////////////////////// catch (Exception e1) { driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS); if (driver.getPageSource().contains("You are NOT authorized to access Site")) { System.out.println("You are NOT authorized to access Site error message is displayed"); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.navigate().to("http://e1.dev.assetnation.com"); SIGNIN(driver, fieldText, value); } } } catch (Exception e) { e.printStackTrace(); resultDetails.setFlag(false); } }
From source file:com.owncloud.android.test.ui.testSuites.UploadTestSuite.java
License:Open Source License
@Test @Category(UnfinishedTestCategory.class) public void testUploadFromGmail() throws Exception { FileListView fileListView = Actions.login(Config.URL, Config.user, Config.password, Config.isTrusted, driver);//from w ww . j a v a 2 s .c o m driver.startActivity("com.google.android.gm", ".ConversationListActivityGmail"); GmailEmailListView gmailEmailListView = new GmailEmailListView(driver); Thread.sleep(3000); GmailEmailView gmailEmailView = gmailEmailListView.clickOnEmail(); ImageView imageView = gmailEmailView.clickOnfileButton(); imageView.clickOnOptionsButton(); imageView.clickOnShareButton(); imageView.clickOnOwnCloudButton(); //justonce button do not appear always try { imageView.clickOnJustOnceButton(); } catch (NoSuchElementException e) { } UploadView uploadView = new UploadView(driver); uploadView.clickOUploadButton(); driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_HOME); driver.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity"); common.wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.name(FILE_GMAIL_NAME))); assertEquals(Config.fileToTestSendByEmailName, driver.findElementByName(FILE_GMAIL_NAME).getText()); fileListView = new FileListView(driver); fileListView.scrollTillFindElement(FILE_GMAIL_NAME); assertTrue(fileHasBeenUploadedFromGmail = fileListView.getFileElement().isDisplayed()); //TODO. correct assert if fileListView is shown in grid mode }
From source file:com.pentaho.ctools.cdf.require.SelectMultiComponent.java
License:Apache License
/** * ############################### Test Case 3 ############################### * * Test Case Name://from w w w. j a va 2 s . co m * Select options one by one * Description: * We pretend validate the selection of each option one by one. * Steps: * 1. Select Southern * 2. Select Eastern * 3. Select Central * 4. Select Western */ @Test public void tc3_SelectEachItem_AlertDisplayed() { this.log.info("tc3_SelectEachItem_AlertDisplayed"); // ## Step 1 wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("select"))); Select list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Southern"); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); String confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern", confirmationMsg); // ## Step 2 list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.deselectByValue("Southern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); alert.accept(); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Eastern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Eastern", confirmationMsg); // ## Step 3 list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.deselectByValue("Eastern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); alert.accept(); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Central"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Central", confirmationMsg); // ## Step 4 list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.deselectByValue("Central"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); alert.accept(); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Western"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Western", confirmationMsg); //RESET list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.deselectByValue("Western"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); alert.accept(); }
From source file:com.pentaho.ctools.cdf.require.SelectMultiComponent.java
License:Apache License
/** * ############################### Test Case 4 ############################### * * Test Case Name:/*from w w w . ja v a 2 s.c o m*/ * Select and deselect all * Description: * We pretend validate the selection and deselection of all options. * Steps: * 1. Select all options * 2. Deselect all options */ @Test public void tc4_SelectAll_AlertDisplayed() { this.log.info("tc4_SelectAll_AlertDisplayed"); // ## Step 1 wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("select"))); Select list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Southern"); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); String confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern", confirmationMsg); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Eastern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Eastern", confirmationMsg); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Central"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Eastern,Central", confirmationMsg); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Western"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Eastern,Central,Western", confirmationMsg); // ## Step 2 list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.deselectByValue("Southern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Eastern,Central,Western", confirmationMsg); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.deselectByValue("Eastern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Central,Western", confirmationMsg); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.deselectByValue("Central"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Western", confirmationMsg); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.deselectByValue("Western"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: ", confirmationMsg); }
From source file:com.pentaho.ctools.cdf.require.SelectMultiComponent.java
License:Apache License
/** * ############################### Test Case 5 ############################### * * Test Case Name:// www . jav a 2s.co m * Select arbitrary * Description: * We pretend validate the selection options arbitrary. * Steps: * 1. Select Arbitrary */ @Test public void tc5_SelectArbitrary_AlertDisplayed() { this.log.info("tc5_SelectArbitrary_AlertDisplayed"); // ## Step 1 wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("select"))); Select list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Eastern"); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); String confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Eastern", confirmationMsg); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Central"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Eastern,Central", confirmationMsg); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Southern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Eastern,Central", confirmationMsg); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.deselectByValue("Eastern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Central", confirmationMsg); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Eastern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Eastern,Central", confirmationMsg); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Western"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Eastern,Central,Western", confirmationMsg); list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.deselectByValue("Central"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Eastern,Western", confirmationMsg); }
From source file:com.pentaho.ctools.cdf.SelectMultiComponent.java
License:Apache License
/** * ############################### Test Case 3 ############################### * * Test Case Name:/*from w w w . java 2 s.com*/ * Select options one by one * Description: * We pretend validate the selection of each option one by one. * Steps: * 1. Select Southern * 2. Select Eastern * 3. Select Central * 4. Select Western */ @Test public void tc3_SelectEachItem_AlertDisplayed() { this.log.info("tc3_SelectEachItem_AlertDisplayed"); // ## Step 1 wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("select"))); Select list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Southern"); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); String confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern", confirmationMsg); // ## Step 2 list.deselectByValue("Southern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); alert.accept(); list.selectByValue("Eastern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Eastern", confirmationMsg); // ## Step 3 list.deselectByValue("Eastern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); alert.accept(); list.selectByValue("Central"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Central", confirmationMsg); // ## Step 4 list.deselectByValue("Central"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); alert.accept(); list.selectByValue("Western"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Western", confirmationMsg); //RESET list.deselectByValue("Western"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); alert.accept(); }
From source file:com.pentaho.ctools.cdf.SelectMultiComponent.java
License:Apache License
/** * ############################### Test Case 4 ############################### * * Test Case Name:/*from w ww. j ava 2 s . c o m*/ * Select and deselect all * Description: * We pretend validate the selection and deselection of all options. * Steps: * 1. Select all options * 2. Deselect all options */ @Test public void tc4_SelectAll_AlertDisplayed() { this.log.info("tc4_SelectAll_AlertDisplayed"); // ## Step 1 wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("select"))); Select list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Southern"); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); String confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern", confirmationMsg); list.selectByValue("Eastern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Eastern", confirmationMsg); list.selectByValue("Central"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Eastern,Central", confirmationMsg); list.selectByValue("Western"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Eastern,Central,Western", confirmationMsg); // ## Step 2 list.deselectByValue("Southern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Eastern,Central,Western", confirmationMsg); list.deselectByValue("Eastern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Central,Western", confirmationMsg); list.deselectByValue("Central"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Western", confirmationMsg); list.deselectByValue("Western"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: ", confirmationMsg); }
From source file:com.pentaho.ctools.cdf.SelectMultiComponent.java
License:Apache License
/** * ############################### Test Case 5 ############################### * * Test Case Name:/* w ww .ja v a2 s .c o m*/ * Select arbitrary * Description: * We pretend validate the selection options arbitrary. * Steps: * 1. Select Arbitrary */ @Test public void tc5_SelectArbitrary_AlertDisplayed() { this.log.info("tc5_SelectArbitrary_AlertDisplayed"); // ## Step 1 wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("select"))); Select list = new Select(this.elemHelper.FindElement(driver, By.cssSelector("select"))); list.selectByValue("Eastern"); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); String confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Eastern", confirmationMsg); list.selectByValue("Central"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Eastern,Central", confirmationMsg); list.selectByValue("Southern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Eastern,Central", confirmationMsg); list.deselectByValue("Eastern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Central", confirmationMsg); list.selectByValue("Eastern"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Eastern,Central", confirmationMsg); list.selectByValue("Western"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Eastern,Central,Western", confirmationMsg); list.deselectByValue("Central"); wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); confirmationMsg = alert.getText(); alert.accept(); assertEquals("you chose: Southern,Eastern,Western", confirmationMsg); }
From source file:nz.co.testamation.core.client.SeleniumBrowserDriver.java
License:Apache License
@Override public void waitForVisible(By by, int timeoutInSeconds) { new WebDriverWait(getDriver(), timeoutInSeconds) .until(ExpectedConditions.visibilityOfAllElementsLocatedBy(by)); }