List of usage examples for org.openqa.selenium.support.ui WebDriverWait WebDriverWait
public WebDriverWait(WebDriver driver, Duration timeout)
From source file:com.contactenergy.Tests.ContactBrowserTest.java
@Test(dataProvider = "devices") public void ResidentialOrderBottleGas_onDesktop(TestDevice device) throws IOException, Exception { load("/Residential/Gas/Stock-up/Order-Bottled-Gas"); Assert.assertTrue("Navigated to Residential Bottled Gas Order", driver.get().findElement(By.xpath("//h1[contains(.,'Bottled Gas Order')]")).isDisplayed()); driver.get().findElement(By.xpath("//input[@id='AccountNumber']")).sendKeys("123456789"); driver.get().findElement(By.xpath("//input[@id='FirstName']")).sendKeys("ResidentialBottleGas"); driver.get().findElement(By.xpath("//input[@id='LastName']")).sendKeys("AutoRegressionBottleGas"); driver.get().findElement(By.xpath("//input[@id='EmailAddress']")).sendKeys("DPTSTTM@contactenergy.co.nz"); driver.get().findElement(By.xpath("//input[@id='PhoneNumber']")).sendKeys("123456789"); scrollto("//h3[contains(.,'Your Property & Outlet')]"); driver.get().findElement(By.xpath("//label[contains(.,'Enter your address')]")).click(); driver.get().findElement(By.xpath("//input[contains(@autocomplete,'off')]")) .sendKeys("1 Bressay Way, Waikanae 5036"); WebDriverWait wait = new WebDriverWait(driver.get(), 15); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[@class='ui-menu-item']"))); driver.get().findElement(By.xpath("//li[@class='ui-menu-item']")).click(); selectoption("Region", "North"); selectoption("Outlet", "FARNORTH"); scrollto("//legend[contains(.,'Stock Up')]"); selectoption("NumberOfCylinders", "1"); driver.get().findElement(By.xpath("//textarea[@id='DeliveryInstructions']")) .sendKeys("Auto Regression Test for ordering Residential Bottle Gas"); // if// ww w . j ava2 s .com // (!driver.get().findElement(By.xpath("//div[contains(@class,'form-submit-border')]")).isEnabled()) // { // driver.get().findElement(By.xpath("//div[contains(@class,'form-submit-border')]")).click(); // driver.get().findElement(By.xpath("//input[@type='submit']")).click(); // } else { driver.get().findElement(By.xpath("//input[@type='submit']")).click(); // } Assert.assertTrue("Navigated to Residential Order Bottle Gas Success Page", driver.get().findElement(By.xpath("//h1[contains(.,'Thanks!')]")).isDisplayed()); }
From source file:com.contactenergy.Tests.ContactBrowserTest.java
@Test(dataProvider = "devices") public void BusinessOrderBottleGas_onDesktop(TestDevice device) throws IOException, Exception { load("/Business/Order-LPG"); Assert.assertTrue("Navigated to Business Bottled Gas Order", driver.get() .findElement(By.xpath("//legend[contains(.,'Your details and delivery details')]")).isDisplayed()); driver.get().findElement(By.xpath("//label[contains(.,'Your Account Number')]")); driver.get()/*from www .j a v a2 s . co m*/ .findElement( By.xpath("//input[@id='wffmb46af2c670fd4482b8e0b9d10755a172_Sections_0__Fields_0__Value']")) .sendKeys("123456789"); driver.get() .findElement( By.xpath("//input[@id='wffmb46af2c670fd4482b8e0b9d10755a172_Sections_0__Fields_1__Value']")) .sendKeys("ResidentialBottleGas"); driver.get() .findElement( By.xpath("//input[@id='wffmb46af2c670fd4482b8e0b9d10755a172_Sections_0__Fields_2__Value']")) .sendKeys("DPTSTTM@contactenergy.co.nz"); driver.get() .findElement( By.xpath("//input[@id='wffmb46af2c670fd4482b8e0b9d10755a172_Sections_0__Fields_3__Value']")) .sendKeys("123456789"); scrollto("//h3[contains(.,'Delivery Address')]"); driver.get().findElement(By.xpath("//label[contains(.,'Start typing your address')]")).click(); driver.get().findElement(By.xpath("//input[contains(@autocomplete,'off')]")) .sendKeys("1 Bressay Way, Waikanae 5036"); WebDriverWait wait = new WebDriverWait(driver.get(), 15); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[@class='ui-menu-item']"))); driver.get().findElement(By.xpath("//li[@class='ui-menu-item']")).click(); scrollto("//legend[contains(.,'What would you like to order today?')]"); selectoption("wffmb46af2c670fd4482b8e0b9d10755a172_Sections_1__Fields_0__Value", "Send me 1 cylinder"); driver.get() .findElement(By.xpath( "//textarea[@id='wffmb46af2c670fd4482b8e0b9d10755a172_Sections_1__Fields_1__Value']")) .sendKeys("Auto Regression Test for ordering Business Bottle Gas"); // driver.get().findElement(By.xpath("//fieldset[contains(.,'What would // you like to order today?')]")).click(); // if // (!driver.get().findElement(By.xpath("//div[contains(@class,'form-submit-border // text-center')]")) // .isEnabled()) { // driver.get().findElement(By.xpath("//div[contains(@class,'form-submit-border // text-center')]")).click(); // driver.get().findElement(By.xpath("//input[@type='submit']")).click(); // } else { driver.get().findElement(By.xpath("//input[@type='submit']")).click(); // } Assert.assertTrue("Navigated to Business Order Bottle Gas Success Page", driver.get().findElement(By.xpath("//h1[contains(.,'Thanks!')]")).isDisplayed()); }
From source file:com.contactenergy.Tests.ContactBrowserTest.java
@Test(dataProvider = "devices") public void BusinessAddPremisesJourney_onDesktop(TestDevice device) throws IOException, Exception { load("/Business/Add-Premises"); scrollto("//legend[contains(.,'A few details about you')]"); Assert.assertTrue("Navigated to Business Add Premises Page", driver.get() .findElement(By.xpath("//legend[contains(.,'A few details about you')]")).isDisplayed()); driver.get()//ww w . j a v a2 s.c o m .findElement( By.xpath("//input[@id='wffm6a38e4b99016497182c31dade512e220_Sections_0__Fields_0__Value']")) .sendKeys("AutoRegression"); driver.get() .findElement( By.xpath("//input[@id='wffm6a38e4b99016497182c31dade512e220_Sections_0__Fields_1__Value']")) .sendKeys("AutoRegression"); driver.get() .findElement( By.xpath("//input[@id='wffm6a38e4b99016497182c31dade512e220_Sections_0__Fields_2__Value']")) .sendKeys("DPTSTTM@contactenergy.co.nz"); driver.get() .findElement( By.xpath("//input[@id='wffm6a38e4b99016497182c31dade512e220_Sections_0__Fields_3__Value']")) .sendKeys("1231312232"); driver.get() .findElement( By.xpath("//input[@id='wffm6a38e4b99016497182c31dade512e220_Sections_1__Fields_0__Value']")) .sendKeys("1231312232"); driver.get().findElement(By.xpath("//label[contains(.,'Start typing your address')]")).click(); driver.get().findElement(By.xpath("//input[contains(@autocomplete,'off')]")) .sendKeys("1 Bressay Way, Waikanae 5036"); WebDriverWait wait = new WebDriverWait(driver.get(), 15); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[@class='ui-menu-item']"))); driver.get().findElement(By.xpath("//li[@class='ui-menu-item']")).click(); // driver.get() // .findElement( // By.xpath("//input[@id='wffm6a38e4b99016497182c31dade512e220_Sections_2__Fields_0__Value']")) // .sendKeys("Adding Premises"); scrollto("//legend[contains(.,'How else can we help you today?')]"); driver.get() .findElement(By.xpath( "//textarea[@id='wffm6a38e4b99016497182c31dade512e220_Sections_2__Fields_0__Value']")) .sendKeys("Auto Regression Test for Adding Business Premises"); selectoption("wffm6a38e4b99016497182c31dade512e220_Sections_2__Fields_1__Value", "Business Freedom"); scrollandclick("//input[@type='submit']"); Assert.assertTrue("Navigated to Business Add Premises Success Page", driver.get().findElement(By.xpath("//h1[contains(.,'Roger that!')]")).isDisplayed()); }
From source file:com.contactenergy.Tests.ContactBrowserTest.java
@Test(dataProvider = "devices") public void BusinessMovePremisesJourney_onDesktop(TestDevice device) throws IOException, Exception { load("/Business/Move-Premises"); scrollto("//legend[contains(.,'A few details about you')]"); Assert.assertTrue("Navigated to Business Add Premises Page", driver.get() .findElement(By.xpath("//legend[contains(.,'A few details about you')]")).isDisplayed()); driver.get()/*from ww w . ja va2s . c o m*/ .findElement( By.xpath("//input[@id='wffme6ce7e0dd0744175962be943e5857879_Sections_0__Fields_0__Value']")) .sendKeys("AutoRegression"); driver.get() .findElement( By.xpath("//input[@id='wffme6ce7e0dd0744175962be943e5857879_Sections_0__Fields_1__Value']")) .sendKeys("AutoRegression"); driver.get() .findElement( By.xpath("//input[@id='wffme6ce7e0dd0744175962be943e5857879_Sections_0__Fields_2__Value']")) .sendKeys("DPTSTTM@contactenergy.co.nz"); driver.get() .findElement( By.xpath("//input[@id='wffme6ce7e0dd0744175962be943e5857879_Sections_0__Fields_3__Value']")) .sendKeys("1231312232"); driver.get() .findElement( By.xpath("//input[@id='wffme6ce7e0dd0744175962be943e5857879_Sections_1__Fields_0__Value']")) .sendKeys("1231312232"); driver.get().findElement(By.xpath("//label[contains(.,'Start typing your address')]")).click(); driver.get().findElement(By.xpath("//input[contains(@autocomplete,'off')]")) .sendKeys("1 Bressay Way, Waikanae 5036"); WebDriverWait wait = new WebDriverWait(driver.get(), 15); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[@class='ui-menu-item']"))); driver.get().findElement(By.xpath("//li[@class='ui-menu-item']")).click(); // driver.get() // .findElement( // By.xpath("//input[@id='wffme6ce7e0dd0744175962be943e5857879_Sections_2__Fields_0__Value']")) // .sendKeys("Moving Premises"); scrollto("//legend[contains(.,'How else can we help you today?')]"); driver.get() .findElement(By.xpath( "//textarea[@id='wffme6ce7e0dd0744175962be943e5857879_Sections_2__Fields_0__Value']")) .sendKeys("Auto Regression Test for Moving Business Premises"); selectoption("wffme6ce7e0dd0744175962be943e5857879_Sections_2__Fields_1__Value", "Business Freedom"); scrollandclick("//input[@type='submit']"); Assert.assertTrue("Navigated to Business Move Premises Success Page", driver.get().findElement(By.xpath("//h1[contains(.,'Roger that!')]")).isDisplayed()); }
From source file:com.contactenergy.Tests.ContactBrowserTest.java
@Test(dataProvider = "devices") public void BusinessJoinJourney_onDesktop(TestDevice device) throws IOException, Exception { load("/Business/Submit-an-Enquiry"); scrollto("//legend[contains(.,'A few details about you')]"); Assert.assertTrue("Navigated to Business Add Premises Page", driver.get() .findElement(By.xpath("//legend[contains(.,'A few details about you')]")).isDisplayed()); driver.get()/*www .ja va 2 s. c o m*/ .findElement( By.xpath("//input[@id='wffm0ecdf726e4874fcc90a1ce71dd457dd0_Sections_0__Fields_0__Value']")) .sendKeys("AutoRegression"); driver.get() .findElement( By.xpath("//input[@id='wffm0ecdf726e4874fcc90a1ce71dd457dd0_Sections_0__Fields_1__Value']")) .sendKeys("AutoRegression"); driver.get() .findElement( By.xpath("//input[@id='wffm0ecdf726e4874fcc90a1ce71dd457dd0_Sections_0__Fields_2__Value']")) .sendKeys("DPTSTTM@contactenergy.co.nz"); driver.get() .findElement( By.xpath("//input[@id='wffm0ecdf726e4874fcc90a1ce71dd457dd0_Sections_0__Fields_3__Value']")) .sendKeys("1231312232"); driver.get() .findElement( By.xpath("//input[@id='wffm0ecdf726e4874fcc90a1ce71dd457dd0_Sections_1__Fields_0__Value']")) .sendKeys("1231312232"); driver.get().findElement(By.xpath("//label[contains(.,'Start typing your address')]")).click(); driver.get().findElement(By.xpath("//input[contains(@autocomplete,'off')]")) .sendKeys("1 Bressay Way, Waikanae 5036"); WebDriverWait wait = new WebDriverWait(driver.get(), 15); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[@class='ui-menu-item']"))); driver.get().findElement(By.xpath("//li[@class='ui-menu-item']")).click(); scrollto("//legend[contains(.,'How can we help you today?')]"); selectoption("wffm0ecdf726e4874fcc90a1ce71dd457dd0_Sections_2__Fields_0__Value", "Sign up as a business customer"); driver.get() .findElement(By.xpath( "//textarea[@id='wffm0ecdf726e4874fcc90a1ce71dd457dd0_Sections_2__Fields_1__Value']")) .sendKeys("Auto Regression Test for Business Join"); selectoption("wffm0ecdf726e4874fcc90a1ce71dd457dd0_Sections_2__Fields_2__Value", "Business Fuel Rewards Plus"); scrollandclick("//input[@type='submit']"); Assert.assertTrue("Navigated to Business Join Success Page", driver.get().findElement(By.xpath("//h1[contains(.,'Roger that!')]")).isDisplayed()); }
From source file:com.contactenergy.Tests.ContactBrowserTest.java
@Test(dataProvider = "devices") public void BusinessBottleGasSignUpJourney_onDesktop(TestDevice device) throws IOException, Exception { load("/Business/Bottled-Gas-Signup"); scrollto("//legend[contains(.,'Tell us about your business')]"); Assert.assertTrue("Navigated to Business SignUp for Order BottleGas Page", driver.get() .findElement(By.xpath("//legend[contains(.,'Tell us about your business')]")).isDisplayed()); driver.get()/*from w w w . ja va2 s . co m*/ .findElement( By.xpath("//input[@id='wffm6672788511ce4be19f84d4aea057a2ce_Sections_0__Fields_0__Value']")) .sendKeys("AutoRegressionBusiness Bottle Gas"); driver.get().findElement(By.xpath("//label[contains(.,'Start typing your address')]")).click(); driver.get().findElement(By.xpath("//input[contains(@autocomplete,'off')]")) .sendKeys("1 Bressay Way, Waikanae 5036"); WebDriverWait wait = new WebDriverWait(driver.get(), 15); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[@class='ui-menu-item']"))); driver.get().findElement(By.xpath("//li[@class='ui-menu-item']")).click(); driver.get() .findElement(By.xpath( "//textarea[@id='wffm6672788511ce4be19f84d4aea057a2ce_Sections_0__Fields_2__Value']")) .sendKeys("Auto Regression Test for Business Order Bottle SignUp"); driver.get() .findElement( By.xpath("//input[@id='wffm6672788511ce4be19f84d4aea057a2ce_Sections_1__Fields_0__Value']")) .sendKeys("FirstNameAutoRegression"); driver.get() .findElement( By.xpath("//input[@id='wffm6672788511ce4be19f84d4aea057a2ce_Sections_1__Fields_1__Value']")) .sendKeys("LastNameAutoRegression"); driver.get() .findElement( By.xpath("//input[@id='wffm6672788511ce4be19f84d4aea057a2ce_Sections_1__Fields_2__Value']")) .sendKeys("JobAutoRegression"); driver.get() .findElement( By.xpath("//input[@id='wffm6672788511ce4be19f84d4aea057a2ce_Sections_1__Fields_3__Value']")) .sendKeys("DPTSTTM@contactenergy.co.nz"); driver.get() .findElement( By.xpath("//input[@id='wffm6672788511ce4be19f84d4aea057a2ce_Sections_1__Fields_4__Value']")) .sendKeys("1231312232"); selectoption("wffm6672788511ce4be19f84d4aea057a2ce_Sections_1__Fields_5__Value", "I'd prefer a call in the morning"); scrollandclick("//input[@type='submit']"); Assert.assertTrue("Navigated to Business Bottle Gas Signup Success Page", driver.get().findElement(By.xpath("//h1[contains(.,'Roger that!')]")).isDisplayed()); }
From source file:com.conwet.silbops.EndToEndHTMLIT.java
License:Open Source License
private void waitMessage(final String id, final String message) { new WebDriverWait(browser, 5).until(new ExpectedCondition<Boolean>() { @Override//from w w w . j a v a 2 s. c o m public Boolean apply(WebDriver driver) { return getTextAreaValue(id).contains(message); } }); }
From source file:com.daarons.transfer.DownloadTask.java
License:Apache License
private void initDownloadTask() { initChromeDriver();/*from w w w . ja va2s .co m*/ longWait = new WebDriverWait(driver, 60); smallWait = new WebDriverWait(driver, 3); driver.get("https://wetransfer.com/sign-in"); }
From source file:com.daarons.transfer.UploadTask.java
License:Apache License
@Override protected Object call() throws Exception { initUploadTask();/* ww w . j a v a 2 s .c om*/ acceptToS(); //put before login? String emailAddress = getTransferSettingsController().getEmailAddress(); String password = getTransferSettingsController().getPassword(); boolean loggedIn = false; if (!emailAddress.isEmpty() && !password.isEmpty()) { loggedIn = logIn(emailAddress, password); } Iterator<UploadTransferObject> i = uploadList.iterator(); while (i.hasNext()) { UploadTransferObject uploadTransferObject = i.next(); clickButtonToChooseEmailOrLink(); Message message = uploadTransferObject.getMessage(); boolean sendingEmail = false; boolean gettingLink = false; if (message != null) { clickEmailButton(); inputMessage(message); sendingEmail = true; } else { clickLinkButton(); gettingLink = true; } String uploadPassword = uploadTransferObject.getPassword(); if (uploadPassword != null && loggedIn) { enterUploadPassword(uploadPassword); } clickButtonToChooseEmailOrLink(); inputFilePath(uploadTransferObject.getUrl()); clickTransferButtonWithText("Transfer"); String downloadLink = null; int timeWaited = 0; boolean isUploadTimeAvailable = isUploadTimeAvailable(longWait); boolean isLinkAvailable = false; boolean isEmailSent = false; if (!isUploadTimeAvailable) { //check if the upload if finished. Maybe it was a small file and uploaded quickly. if (sendingEmail) { isEmailSent = isTransferButtonWithTextAvailable("Send another?", longWait); } else if (gettingLink) { isLinkAvailable = isLinkAvailable(smallWait); } //if upload isn't finished if (!isEmailSent && !isLinkAvailable) { //look for upload time again isUploadTimeAvailable = isUploadTimeAvailable(longWait); if (!isUploadTimeAvailable) { log.error("Couldn't upload this file. Continuing to next file."); TransferRecord transferRecord = createTransferRecord(uploadTransferObject, "Failed"); dao.addTransferRecord(transferRecord); continue; } } } if (isUploadTimeAvailable) { int timeUntilUploadFinished = getUploadTime(smallWait); //create new webdriverwait based on upload time + some extra time //just in case slow connection WebDriverWait uploadWait = new WebDriverWait(driver, (timeUntilUploadFinished * 60) + (30 * 60)); if (sendingEmail) { isEmailSent = isTransferButtonWithTextAvailable("Send another?", uploadWait); } else if (gettingLink) { isLinkAvailable = isLinkAvailable(uploadWait); } if (!isEmailSent && !isLinkAvailable) { log.error("The upload time is done, but the web element cannot be found"); if (isUploadTimeAvailable(smallWait)) { timeWaited += (timeUntilUploadFinished * 60) + (30 * 60); timeUntilUploadFinished = getUploadTime(smallWait); uploadWait = new WebDriverWait(driver, (timeUntilUploadFinished * 60) + (30 * 60)); //calculate time waited if there's a future failure timeWaited += (timeUntilUploadFinished * 60) + (30 * 60); timeWaited /= 60;//time waited in minutes for failure if (sendingEmail) { isEmailSent = isTransferButtonWithTextAvailable("Send another?", uploadWait); } else if (gettingLink) { isLinkAvailable = isLinkAvailable(uploadWait); } if (!isEmailSent && !isLinkAvailable) { log.error("Couldn't upload this file. Continuing to next file."); TransferRecord transferRecord = createTransferRecord(uploadTransferObject, "Failed"); dao.addTransferRecord(transferRecord); continue; } } else if (sendingEmail && !isTransferButtonWithTextAvailable("Send another?", smallWait)) { log.error("Couldn't upload this file. Continuing to next file."); TransferRecord transferRecord = createTransferRecord(uploadTransferObject, "Failed"); dao.addTransferRecord(transferRecord); continue; } else if (gettingLink && !isLinkAvailable(smallWait)) { log.error("Couldn't upload this file. Continuing to next file."); TransferRecord transferRecord = createTransferRecord(uploadTransferObject, "Failed"); dao.addTransferRecord(transferRecord); continue; } } } WebElement linkElement = null; if (gettingLink) { linkElement = smallWait .until(ExpectedConditions.presenceOfElementLocated(By.className("transfer__textfield"))); downloadLink = linkElement.getAttribute("value"); } if (sendingEmail) { downloadLink = message.getTo().replaceAll(",", " "); } TransferRecord transferRecord = createTransferRecord(uploadTransferObject, downloadLink); dao.addTransferRecord(transferRecord); try { if (gettingLink) { linkElement.click(); clickTransferButtonWithText("Ok"); } else if (isEmailSent) { clickTransferButtonWithText("Send another?"); } clickTransferButtonWithText("Continue"); Thread.sleep(5000); } catch (Exception ex) { log.error("Couldn't click button. Uploading next file.", ex); } } if (loggedIn) { logOut(); try { Thread.sleep(3000); } catch (InterruptedException ex) { log.error(ex); } } clearTableView("upload"); driver.quit(); return null; }
From source file:com.daarons.transfer.UploadTask.java
License:Apache License
private void initUploadTask() { initChromeDriver();// ww w . ja va2 s. co m longWait = new WebDriverWait(driver, 60); smallWait = new WebDriverWait(driver, 3); driver.get("https://wetransfer.com/sign-in"); }