List of usage examples for org.openqa.selenium.support.ui ExpectedConditions elementToBeClickable
public static ExpectedCondition<WebElement> elementToBeClickable(final WebElement element)
From source file:com.dhenton9000.selenium.generic.WaitMethods.java
public void waitForElementToBeClickable(int timeInSeconds, SELECTOR_CHOICE selectorChoice, String selectorValue) {// w w w. j a va 2 s. c o m WebDriverWait wait = new WebDriverWait(driver, timeInSeconds); By selectionBy = generateSelectorBy(selectorChoice, selectorValue); wait.until(ExpectedConditions.elementToBeClickable(selectionBy)); }
From source file:com.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Broadband_Util.java
protected void clickOnRadioRM50() { boolean breakIt; while (true) { breakIt = true;//from w w w . jav a 2s .co m try { // Put email id on text field as it can not be blank //*[@id="reloadForm__email"] WebElement emailtxt = getDriver().findElement(By.id("reloadForm__email")); System.out.println(emailtxt.isEnabled()); if (emailtxt.isEnabled()) { handleInputField_ByID("reloadForm__email", AppConstants.EMAIL); Thread.sleep(500); } JavascriptExecutor js1 = (JavascriptExecutor) getDriver(); //js1.executeScript("window.scrollBy(0,400)", ""); //*[@id="prepaidReloadForm"]/ul/li[2]/label/div 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(getDriver(), 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); breakIt = false; e.printStackTrace(); log.error("Fail : Failed to Reload amount."); System.exit(0); } if (breakIt) { break; } } //while ends }
From source file:com.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Util.java
/** * Reads and downloads month history/*from ww w . j a v a2 s . c om*/ * @param index */ protected void downloadMonthHistory(int index) { WebDriverWait wait = new WebDriverWait(getDriver(), 30); boolean breakIt; while (true) { breakIt = true; try { waitgetForPageLoad(30); getDropdownmonths().get(index).click(); wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='downloadPrepaidReport']"))); // waitgetForPageLoad(30).until(ExpectedCondition.visibilityOfElementLocated(By.xpath("//*[@id='downloadPrepaidReport']"))); getDriver().findElement(By.xpath("//*[@id='downloadPrepaidReport']")).click(); System.out.println("********downloaded**********"); getDriver().manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); } catch (Exception e) { breakIt = false; } if (breakIt) { break; } } }
From source file:com.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Util.java
protected void clickOnRadioRM50() { try {/*from w w w .j av a 2s.c o m*/ // Put email id on text field as it can not be blank //*[@id="reloadForm__email"] WebElement emailtxt = getDriver().findElement(By.id("reloadForm__email")); System.out.println(emailtxt.isEnabled()); if (emailtxt.isEnabled()) { handleInputField_ByID("reloadForm__email", AppConstants.EMAIL); Thread.sleep(500); } JavascriptExecutor js1 = (JavascriptExecutor) getDriver(); js1.executeScript("window.scrollBy(0,400)", ""); //*[@id="prepaidReloadForm"]/ul/li[2]/label/div 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(getDriver(), 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.common.PageNavigation.java
protected void clickOnRadioRM25Broadband() { try {/*from w w w . j a va 2s . 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[5]/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.common.PageNavigation.java
protected WebElement tryToClickElementByXPath(String xpath, int maxtry) { Wait<WebDriver> waittable = new WebDriverWait(getDriver(), 30); WebElement element = null;/*from ww w .j a v a2 s . co m*/ int trycount = 1; boolean breakit; while (trycount != maxtry) { breakit = true; try { element = waittable.until(ExpectedConditions.elementToBeClickable(By.xpath(xpath))); } catch (Exception e) { breakit = false; trycount++; } if (breakit == true) break; } return element; }
From source file:com.digi.selenium.util.PageNavigation.java
protected void paymentPostpaidBroadband() { try {// w ww. j a va 2 s .c o m JavascriptExecutor jse = (JavascriptExecutor) getDriver(); jse.executeScript("window.scrollBy(0,-500)", ""); //*[@id="planDetails"]/div[2]/div[1]/div[6]/button WebElement pay = getDriver() .findElement(By.xpath("//*[@id='planDetails']/div[2]/div[1]/div[6]/button")); pay.click(); waitForPageLoad(100); //*[@id="rp-form-field-payamount"] driver.findElement(By.id("rp-form-field-payamount")).clear(); handleInputField_ByID("rp-form-field-payamount", AppConstants.RMVALUE); JavascriptExecutor jse1 = (JavascriptExecutor) getDriver(); jse1.executeScript("window.scrollBy(0,500)", ""); //*[@id="proceed-button"]/span[1] WebElement payment = (new WebDriverWait(driver, 1000)) .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceed-button']/span[1]"))); payment.click(); waitForPageLoad(20); Thread.sleep(500); WebElement payment2 = (new WebDriverWait(driver, 1000)) .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceed-button']/span[1]"))); payment2.click(); waitForPageLoad(100); } catch (Exception e) { log.error("Fail : Failed to initialize Payment"); e.printStackTrace(); System.exit(0); } }
From source file:com.digi.selenium.util.PageNavigation.java
protected void cancelPaymentPageandReturn() { try {// w w w . ja v a 2s .com //Back to Accounts & Plans JavascriptExecutor jse1 = (JavascriptExecutor) getDriver(); jse1.executeScript("window.scrollBy(0,500)", ""); //*[@id="pay-getaway-foot"]/div[2]/button[3] WebElement cancel = (new WebDriverWait(driver, 1000)).until(ExpectedConditions .elementToBeClickable(By.xpath("//*[@id='pay-getaway-foot']/div[2]/button[3]"))); cancel.click(); Thread.sleep(500); getDriver().switchTo().alert().accept(); waitForPageLoad(100); } catch (Exception e) { log.error("Fail : Failed to initialize Payment"); e.printStackTrace(); System.exit(0); } }
From source file:com.digi.selenium.util.PageNavigation.java
protected void returnOnAccountsPage() { try {/*from w w w .jav a 2 s .c o m*/ WebElement back = (new WebDriverWait(driver, 1000)).until( ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='menu-section']/div/ul/li[5]/a"))); back.click(); } catch (Exception e) { log.error("Fail : Failed to initialize Payment"); e.printStackTrace(); System.exit(0); } }
From source file:com.digi.selenium.util.PageNavigation.java
protected void paymentPostpaid() { try {/* w w w. ja va 2 s . co m*/ JavascriptExecutor jse = (JavascriptExecutor) getDriver(); jse.executeScript("window.scrollBy(0,-500)", ""); //*[@id="planDetails"]/div[2]/div[1]/div[6]/button WebElement pay = getDriver() .findElement(By.xpath("//*[@id='planDetails']/div[2]/div[1]/div[6]/button")); pay.click(); waitForPageLoad(100); //*[@id="rp-form-field-payamount"] driver.findElement(By.id("rp-form-field-payamount")).clear(); handleInputField_ByID("rp-form-field-payamount", AppConstants.RMVALUE); JavascriptExecutor jse1 = (JavascriptExecutor) getDriver(); jse1.executeScript("window.scrollBy(0,500)", ""); //*[@id="proceed-button"]/span[1] WebElement payment = (new WebDriverWait(driver, 1000)) .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceed-button']/span[1]"))); payment.click(); waitForPageLoad(20); Thread.sleep(500); WebElement payment2 = (new WebDriverWait(driver, 1000)) .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceed-button']/span[1]"))); payment2.click(); Thread.sleep(1000); waitForPageLoad(100); } catch (Exception e) { log.error("Fail : Failed to initialize Payment"); e.printStackTrace(); System.exit(0); } }