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.BillNReload.Bill_n_Reload_Prepaid_Util.java
/** * Reads and downloads month history/*from w w w . j a va 2 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 targetFinalAmt() { WebDriverWait wait = new WebDriverWait(getDriver(), 20); try {/* w w w . j a v a2 s . c o m*/ //*[@id='content']/div/div/div[1]/div[9]/div[2]/strong wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//*[@id='content']/div/div/div[1]/div[9]/div[2]/strong"))); WebElement amt = getDriver() .findElement(By.xpath("//*[@id='content']/div/div/div[1]/div[9]/div[2]/strong")); finalamt = amt.getText(); } catch (Exception e) { log.error("Fail : To validate the targetAir time amount on Payment Page"); } }
From source file:com.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Util.java
protected void clickOnRadioRM50() { try {// w ww .j a v a2 s. 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.BillNReload.Bill_n_Reload_Prepaid_Util.java
/** * Reads Y_Axis Data for 30,60,90 days/*from ww w .j a v a 2 s.c o m*/ * @param index */ protected void getYAxisData(int index) { boolean breakIt = true; while (true) { breakIt = true; try { JavascriptExecutor jse = (JavascriptExecutor) getDriver(); getWebElement_By_xpath("//div[9]/div[1]/div[2]/ul/li[" + index + "]/a").click(); Wait<WebDriver> wait = new WebDriverWait(getDriver(), 30); if (index == 1) { jse.executeScript("window.scrollBy(0,-210)", ""); jse.executeScript("window.scrollBy(0,210)", ""); } wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//*[name()='svg']/*[name()='g'][13]/*[name()='g'][2]"))); //Working :get the stroke attribute to get the color value of graph getDriver().manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); //boolean breakIt = true; //Get the BillCycle Elements String yaxisrootNodeXpath = "//*[name()='svg']/*[name()='g'][13]/*[name()='g'][2]"; WebElement yaxisrootElement = getDriver().findElement(By.xpath(yaxisrootNodeXpath)); String yaxischildXpath = "./*[name()='text']"; listyaxischild = yaxisrootElement.findElements(By.xpath(yaxischildXpath)); int eleListSize = listyaxischild.size(); // String targetrootdatapath= "//*[@id='content']/div[9]/div[1]/div[1]/div[2]/div/div/svg/g[13]/g[2]"; if (index == 1) System.out.println("===========30 Days Y-AxisData========"); else { if (index == 2) System.out.println("===========60 Days Y-AxisData========"); else System.out.println("===========90 Days Y-AxisData========"); } } //try ends catch (Exception e) { e.printStackTrace(); breakIt = false; } if (breakIt) { break; } } //while loop ends }
From source file:com.digi.selenium.util.common.PageNavigation.java
protected void clickOnRadioRM25Broadband() { try {// ww w . j av a2 s.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 Wait<WebDriver> waitgetForPageLoad(long waitTime) { // try{/*from w w w.j a v a 2s . co m*/ 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.digi.selenium.util.common.PageNavigation.java
protected WebElement tryToGetElementByXPath(String xpath, int maxtry) { Wait<WebDriver> waittable = new WebDriverWait(getDriver(), 30); WebElement element = null;/* w w w . jav a2 s .c o m*/ int trycount = 1; boolean breakit; while (trycount != maxtry) { breakit = true; try { element = waittable.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath))); } catch (Exception e) { breakit = false; trycount++; } if (breakit == true) break; } return element; }
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 www. j ava 2s . c om*/ 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 {/*from ww w.j a va 2s . 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 {//from w ww .j av a 2 s .c o m //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); } }