List of usage examples for org.openqa.selenium.support.ui WebDriverWait WebDriverWait
public WebDriverWait(WebDriver driver, Duration timeout)
From source file:com.digi.selenium.util.PageNavigation.java
protected void backToAccountsAndPaymentsPage() { try {//from w ww . j a v a 2s .c o m //*[@id="menu-section"]/div/ul/li[5]/a WebElement back = (new WebDriverWait(driver, 1000)).until( ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='menu-section']/div/ul/li[5]/a"))); back.click(); waitForPageLoad(100); } catch (Exception e) { System.out.println(e); e.printStackTrace(); log.error("Fail : Failed to Reload amount."); System.exit(0); } }
From source file:com.digi.selenium.util.PageNavigation.java
protected void clickOnRadioRM30() { try {//from w w w. ja v a 2 s . co m WebElement emailtxt = getDriver().findElement(By.id("reloadForm__email")); if (emailtxt.isDisplayed()) { handleInputField_ByID("reloadForm__email", AppConstants.EMAIL); Thread.sleep(500); } JavascriptExecutor js1 = (JavascriptExecutor) getDriver(); js1.executeScript("window.scrollBy(0,400)", ""); WebElement radio = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/ul/li[3]/label/div")); radio.click(); // now select check box to accept license agreement WebElement checkbox = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/label/div")); checkbox.click(); // click on proceed button after selecting radio button and check box // WebElement elementproceed=getDriver().findElement(By.xpath("//*[@id='proceedBtn']")); //*[@id="proceedBtn"] WebElement proceed = (new WebDriverWait(driver, 1000)) .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceedBtn']"))); proceed.click(); waitForPageLoad(100); Thread.sleep(500); JavascriptExecutor js = (JavascriptExecutor) getDriver(); js.executeScript("window.scrollBy(0,500)", ""); } catch (Exception e) { System.out.println(e); e.printStackTrace(); log.error("Fail : Failed to Reload amount."); System.exit(0); } }
From source file:com.digi.selenium.util.PageNavigation.java
protected void clickOnRadioRM50() { try {//from ww w .j a va2s . c o m WebElement emailtxt = getDriver().findElement(By.id("reloadForm__email")); if (emailtxt.isDisplayed()) { handleInputField_ByID("reloadForm__email", AppConstants.EMAIL); Thread.sleep(500); } JavascriptExecutor js1 = (JavascriptExecutor) getDriver(); js1.executeScript("window.scrollBy(0,400)", ""); WebElement radio = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/ul/li[4]/label/div")); radio.click(); // now select check box to accept license agreement WebElement checkbox = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/label/div")); checkbox.click(); // click on proceed button after selecting radio button and check box // WebElement elementproceed=getDriver().findElement(By.xpath("//*[@id='proceedBtn']")); //*[@id="proceedBtn"] WebElement proceed = (new WebDriverWait(driver, 1000)) .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceedBtn']"))); proceed.click(); waitForPageLoad(100); Thread.sleep(500); JavascriptExecutor js = (JavascriptExecutor) getDriver(); js.executeScript("window.scrollBy(0,500)", ""); } catch (Exception e) { System.out.println(e); e.printStackTrace(); log.error("Fail : Failed to Reload amount."); System.exit(0); } }
From source file:com.digi.selenium.util.PageNavigation.java
protected void clickOnRadioRM100() { try {//from www . j a v a 2 s . c om WebElement emailtxt = getDriver().findElement(By.id("reloadForm__email")); if (emailtxt.isDisplayed()) { handleInputField_ByID("reloadForm__email", AppConstants.EMAIL); Thread.sleep(500); } JavascriptExecutor js1 = (JavascriptExecutor) getDriver(); js1.executeScript("window.scrollBy(0,400)", ""); WebElement radio = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/ul/li[1]/label/div")); radio.click(); // now select check box to accept license agreement WebElement checkbox = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/label/div")); checkbox.click(); // click on proceed button after selecting radio button and check box // WebElement elementproceed=getDriver().findElement(By.xpath("//*[@id='proceedBtn']")); //*[@id="proceedBtn"] WebElement proceed = (new WebDriverWait(driver, 1000)) .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceedBtn']"))); proceed.click(); waitForPageLoad(100); Thread.sleep(500); JavascriptExecutor js = (JavascriptExecutor) getDriver(); js.executeScript("window.scrollBy(0,500)", ""); } catch (Exception e) { System.out.println(e); e.printStackTrace(); log.error("Fail : Failed to Reload amount."); System.exit(0); } }
From source file:com.digi.selenium.util.PageNavigation.java
protected Wait<WebDriver> waitgetForPageLoad(long waitTime) { try {/*from www . j a v a2 s .c om*/ wait = new WebDriverWait(driver, waitTime); } catch (Exception e) { //System.out.println("Fail : waitForPageLoad() failed"); log.error("Fail : waitgetForPageLoad() failed"); } return wait; }
From source file:com.easytox.automation.steps.LabClientImpl.java
@When("^Select Settings -> Lab Client$") public void select_settings_then_lab_client() { WebElement el = MyWebDriverUtils.findElement(driver, SETTINGS_LOCATOR, LocatorType.CSS); WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS); boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID); if (flag) {/*from w ww.j av a2 s . c o m*/ checkAndClick(el); } else { Assert.fail("flag is false!"); } WebElement lab = MyWebDriverUtils.findElement(driver, LAB_CLIENT_LOCATOR, LocatorType.CSS); checkAndClick(lab); }
From source file:com.easytox.automation.steps.LabClientImpl.java
@When("^Click Add Lab Client '\\+' icon displayed$") public void click_plus_icon() { WebElement el = MyWebDriverUtils.findElement(driver, ADD_LIB_CLIENT_LOCATOR, LocatorType.CSS); WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS); boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID); if (flag) {//from w w w .ja v a 2 s . com checkAndClick(el); } else { Assert.fail("flag is false!"); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@When("^Enter all the information in the screen and click Submit$") public void enter_all_the_information_in_the_screen_and_click_submit() { WebElement business = MyWebDriverUtils.findElement(driver, BUSINESS_NAME_LOCATOR, LocatorType.NAME); if (business != null) { business.clear();// ww w.ja v a 2 s.c om business.sendKeys(BUSINESS_NAME_VALUE); } else { Assert.fail("business is null!"); } WebElement address1 = MyWebDriverUtils.findElement(driver, ADDRESS_1_LOCATOR, LocatorType.NAME); if (address1 != null) { address1.clear(); address1.sendKeys(ADDRESS_1_VALUE); } else { Assert.fail("address1 is null!"); } WebElement address2 = MyWebDriverUtils.findElement(driver, ADDRESS_2_LOCATOR, LocatorType.NAME); if (address2 != null) { address2.clear(); address2.sendKeys(ADDRESS_2_VALUE); } else { Assert.fail("address2 is null!"); } WebElement zipCode = MyWebDriverUtils.findElement(driver, ZIP_LOCATOR, LocatorType.ID); if (zipCode != null) { zipCode.clear(); zipCode.sendKeys(ZIP_VALUE); } else { Assert.fail("zipCode is null!"); } WebElement city = MyWebDriverUtils.findElement(driver, CITY_LOCATOR, LocatorType.ID); if (city != null) { city.clear(); city.sendKeys(CITY_VALUE); } else { Assert.fail("city is null!"); } WebElement state = MyWebDriverUtils.findElement(driver, STATE_LOCATOR, LocatorType.ID); if (state != null) { state.clear(); state.sendKeys(STATE_VALUE); } else { Assert.fail("state is null!"); } WebElement contactPerson = MyWebDriverUtils.findElement(driver, CONTACT_PERSON_LOCATOR, LocatorType.NAME); if (contactPerson != null) { contactPerson.clear(); contactPerson.sendKeys(CONTACT_PERSON_VALUE); } else { Assert.fail("contactPerson is null!"); } WebElement contactNumber = MyWebDriverUtils.findElement(driver, CONTACT_NUMBER_LOCATOR, LocatorType.NAME); if (contactNumber != null) { contactNumber.clear(); contactNumber.sendKeys(CONTACT_NUMBER_VALUE); } else { Assert.fail("contactNumber is null!"); } WebElement faxNumber = MyWebDriverUtils.findElement(driver, FAX_NUMBER_LOCATOR, LocatorType.NAME); if (faxNumber != null) { faxNumber.clear(); faxNumber.sendKeys(FAX_NUMBER_VALUE); } else { Assert.fail("faxNumber is null!"); } WebElement contactEmail = MyWebDriverUtils.findElement(driver, CONTACT_EMAIL_LOCATOR, LocatorType.NAME); if (contactEmail != null) { contactEmail.clear(); contactEmail.sendKeys(CONTACT_EMAIL_VALUE); } else { Assert.fail("contactEmail is null!"); } WebElement submit = MyWebDriverUtils.findElement(driver, SUBMIT_BUTTON_LOCATOR, LocatorType.CSS); WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS); boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID); if (flag) { checkAndClick(submit); } else { Assert.fail("flag is false!"); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@When("^Click '\\+' icon against newly created lab client$") public void click_plus_icon_against_newly_created_lab_clients() { try {/*w ww . j a v a 2 s . c o m*/ final WebElement table = MyWebDriverUtils.findElement(driver, TABLE_LOCATOR, LocatorType.ID); if (table != null) { List<WebElement> listRows = MyWebDriverUtils.findElements(driver, ROWS_LOCATOR, LocatorType.TAG, table); if (listRows != null) { int size = listRows.size(); List<WebElement> listCells = MyWebDriverUtils.findElements(driver, CELL_LOCATOR, LocatorType.TAG, listRows.get(size - 1)); if (listCells != null && listCells.size() == 9) { WebElement el = listCells.get(0); WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS); boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID); if (flag) { checkAndClick(el); } else { Assert.fail("flag is false!"); } } else { throw new StaleElementReferenceException("listCells size is not equal 9"); } } else { Assert.fail("listRows is null!"); } } else { Assert.fail("table is null!"); } } catch (StaleElementReferenceException ex) { click_plus_icon_against_newly_created_lab_clients(); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@When("^Click on a lab client name$") public void click_on_a_lab_client_name() { WebElement el = MyWebDriverUtils.findElement(driver, LAB_CLIENT_NAME, LocatorType.CSS); WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS); boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID); if (flag) {/*from w ww. j a v a2 s. co m*/ checkAndClick(el); } else { Assert.fail("flag is false!"); } }