List of usage examples for org.openqa.selenium.support.ui ExpectedConditions visibilityOfElementLocated
public static ExpectedCondition<WebElement> visibilityOfElementLocated(final By locator)
From source file:TestWriteanArticle.java
@org.junit.Test public void positive() throws InterruptedException { System.setProperty("webdriver.gecko.driver", "C://Users/Mari/Downloads/geckodriver.exe"); WebDriver webDriver = new FirefoxDriver(); String page = "http://www.wikihow.com/Special:CreatePage"; webDriver.get(page);/* w w w . j a v a2 s . c o m*/ WebElement title = webDriver.findElement(By.id("cp_title_input")); title.sendKeys("how to use selenium"); webDriver.findElement(By.id("cp_title_btn")).click(); Thread.sleep(10); WebDriverWait wait = new WebDriverWait(webDriver, 50); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cpr_title_hdr"))); assertTrue(webDriver.getPageSource().contains("Are any of these topics the same as yours?")); webDriver.close(); }
From source file:TestWriteanArticle.java
@org.junit.Test public void negative() throws InterruptedException { System.setProperty("webdriver.gecko.driver", "C://Users/Mari/Downloads/geckodriver.exe"); WebDriver webDriver = new FirefoxDriver(); String page = "http://www.wikihow.com/Special:CreatePage"; webDriver.get(page);//from ww w .ja va 2 s.co m WebElement title = webDriver.findElement(By.id("cp_title_input")); title.sendKeys("how to use wikiHow"); webDriver.findElement(By.id("cp_title_btn")).click(); Thread.sleep(10); WebDriverWait wait = new WebDriverWait(webDriver, 50); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cpr_title_hdr"))); assertTrue(webDriver.getPageSource().contains("That article already exists!")); webDriver.close(); }
From source file:administrationedit.setSeasonTemplate.java
public static void main(String[] args) throws InterruptedException { for (int y = 0; y < 2; y++) { System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe"); driver = new ChromeDriver(); WebDriverWait wait = new WebDriverWait(driver, 3); driver.manage().window().maximize(); Random r = new Random(); Faker faker = new Faker(); driver.get("https://goldfish.dev.hexis.hr/demo/en/administration/accommodation/seasonTemplateAdd"); adminLogin login = new adminLogin(driver); login.loginToAdmin("demo", "demo"); int currentYear = Calendar.getInstance().get(Calendar.YEAR) + y; String curYear = String.valueOf(currentYear); // Input name of template driver.findElement(By.id("name")).sendKeys("Season-" + curYear); // Choose year Select year = new Select(driver.findElement(By.id("year"))); year.selectByVisibleText(curYear); // Now select seasons WebElement tableId = driver.findElement(By.xpath("//*[@class='ui-calendar hasDatepicker']")); if (year.getFirstSelectedOption().getText().equals(curYear)) { String id = tableId.getAttribute("id"); for (int i = 1; i <= 12; i++) { Thread.sleep(1000); for (int j = 1; j <= 7; j++) { if (!driver.findElements(By.xpath( "//*[@id='" + id + "']/div/div[" + i + "]/table/tbody/tr[1]/td[" + j + "]/a")) .isEmpty()) { driver.findElement(By.xpath( "//*[@id='" + id + "']/div/div[" + i + "]/table/tbody/tr[1]/td[" + j + "]/a")) .click(); break; }/*from w w w . ja v a2s. co m*/ } i++; int weeks = driver .findElements(By.xpath("//*[@id='" + id + "']/div/div[" + i + "]/table/tbody/tr")) .size(); int test = 0; for (int j = 7; j >= 1; j--) { if (!driver.findElements(By.xpath("//*[@id='" + id + "']/div/div[" + i + "]/table/tbody/tr[" + weeks + "]/td[" + j + "]/a")).isEmpty()) { test = 1; break; } else test = 2; } switch (test) { case 1: for (int j = 7; j >= 1; j--) { if (!driver.findElements(By.xpath("//*[@id='" + id + "']/div/div[" + i + "]/table/tbody/tr[" + weeks + "]/td[" + j + "]/a")).isEmpty()) { driver.findElement(By.xpath("//*[@id='" + id + "']/div/div[" + i + "]/table/tbody/tr[" + weeks + "]/td[" + j + "]/a")).click(); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( "//*[@id='tab-basic']/div[3]/div[1]/div/div[2]/div/div/div/div/div/div[3]/div/select"))); Select season1 = new Select(driver.findElement(By.xpath( "//*[@id='tab-basic']/div[3]/div[1]/div/div[2]/div/div/div/div/div/div[3]/div/select"))); int season1int = r.nextInt(season1.getOptions().size() - 1) + 1; season1.selectByIndex(season1int); driver.findElement(By.xpath( "//*[@id='tab-basic']/div[3]/div[1]/div/div[2]/div/div/div/div/div/div[4]/div/a[2]")) .click(); break; } } break; case 2: for (int j = 7; j >= 1; j--) { if (!driver.findElements(By.xpath("//*[@id='" + id + "']/div/div[" + i + "]/table/tbody/tr[" + (weeks - 1) + "]/td[" + j + "]/a")).isEmpty()) { driver.findElement(By.xpath("//*[@id='" + id + "']/div/div[" + i + "]/table/tbody/tr[" + (weeks - 1) + "]/td[" + j + "]/a")).click(); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( "//*[@id='tab-basic']/div[3]/div[1]/div/div[2]/div/div/div/div/div/div[3]/div/select"))); Select season2 = new Select(driver.findElement(By.xpath( "//*[@id='tab-basic']/div[3]/div[1]/div/div[2]/div/div/div/div/div/div[3]/div/select"))); int season2int = r.nextInt(season2.getOptions().size() - 1) + 1; season2.selectByIndex(season2int); driver.findElement(By.xpath( "//*[@id='tab-basic']/div[3]/div[1]/div/div[2]/div/div/div/div/div/div[4]/div/a[2]")) .click(); break; } } } } } // SAVE wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//*[@id='page-wrapper']/div[2]/form/div[2]/div/div/div/div[3]/div/input"))); driver.findElement(By.xpath("//*[@id='page-wrapper']/div[2]/form/div[2]/div/div/div/div[3]/div/input")) .click(); if (driver.getTitle().equals("Accommodation season templates administration")) { driver.close(); } } }
From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java
public static void selectApplication(WebDriver driver1, WebDriverWait wait, applications app) throws IOException { if (!isApplicationAlreadySelected(driver1, app)) { logger.info("Selecting application " + app); wait.until(ExpectedConditions .visibilityOfElementLocated(By.id(applangoButtons.APPLICATION_DROP_DOWN.getValue()))); driver1.findElement(By.id(applangoButtons.APPLICATION_DROP_DOWN.getValue())).click(); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(app.getValue()))); driver1.findElement(By.id(app.getValue())).click(); waitUntilWaitForServerDissappears(wait); }/*from w w w.j a va2 s . com*/ }
From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java
public static void clickOnLoginButtonAndWaitForUserListToLoad(WebDriver driver, WebDriverWait wait, boolean isFirstTime) throws IOException { clickOnLogin(driver);/* www.j a v a 2 s.c om*/ wait.until( ExpectedConditions.visibilityOfElementLocated(By.id(applangoObject.HEADER.getValue().toString()))); if (!isFirstTime) { // waitForUserListToLoad(wait); } }
From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java
private static void waitForCredentialsErrorMessage(WebDriver driver, WebDriverWait wait, String errorMessage) throws IOException { wait.until(ExpectedConditions.visibilityOfElementLocated( By.id(applangoObject.INCORRECT_CREDENTIALS_ERRORMESSAGE.getValue().toString()))); Assert.assertTrue(/*from w w w . j av a 2 s . com*/ driver.findElement(By.id(applangoObject.INCORRECT_CREDENTIALS_ERRORMESSAGE.getValue().toString())) .getText().equals(errorMessage)); }
From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java
private static void waitForHistogramToLoad(WebDriverWait wait) throws IOException { logger.info("wait For Histogram To Load"); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(applangoObject.HISTOGRAM.getValue()))) .isDisplayed();//from w w w . j a v a2 s. com }
From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java
public static void selectUserFromList(WebDriver driver1, WebDriverWait wait, String firstName, String lastName) throws IOException { logger.info("Select user from list: " + firstName + " " + lastName); wait.until(// ww w . java 2s . c o m ExpectedConditions.visibilityOfElementLocated(By.id(applangoTextfields.SearchLastName.getValue()))); enterValueInSearchLastName(driver1, lastName); waitForUserListToLoad(wait); if (checkIfUserExistInList(driver1, firstName + " " + lastName)) { if (getNumberOfUsersInList(driver1) == 1) { clickOnRecordInTable(driver1, wait); waitForHistogramToLoad(wait); } else if (getNumberOfUsersInList(driver1) > 1) { clickOnRecordInTable(driver1, wait, firstName + " " + lastName); } } }
From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java
private static void waitForUserAccountPage(WebDriverWait wait) throws IOException { wait.until(ExpectedConditions .visibilityOfElementLocated(By.id(applangoObject.ACCOUNT_TITLE.getValue().toString()))); wait.until(ExpectedConditions// w ww . j a v a 2 s .c om .visibilityOfElementLocated(By.id(applangoButtons.CHANGE_PASSWORD.getValue().toString()))); }
From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java
private static void waitForForgotPasswordDialog(WebDriverWait wait) throws IOException { wait.until(ExpectedConditions .visibilityOfElementLocated(By.id(applangoButtons.CHANGE_PASSWORD_SUBMIT.getValue().toString()))); }