Example usage for org.openqa.selenium.support.ui WebDriverWait WebDriverWait

List of usage examples for org.openqa.selenium.support.ui WebDriverWait WebDriverWait

Introduction

In this page you can find the example usage for org.openqa.selenium.support.ui WebDriverWait WebDriverWait.

Prototype

public WebDriverWait(WebDriver driver, Duration timeout) 

Source Link

Document

Wait will ignore instances of NotFoundException that are encountered (thrown) by default in the 'until' condition, and immediately propagate all others.

Usage

From source file:com.digi.selenium.util.PageNavigation.java

protected void returnOnAccountsPage() {
    try {//from w  ww.j ava 2  s .  c om
        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 {/*from   w  ww  .ja  v a 2  s.c om*/
        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);
    }

}

From source file:com.digi.selenium.util.PageNavigation.java

protected void cancelPaymentAndReturn() {
    try {//from www  .j  a v  a 2s.  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);
    }

}

From source file:com.digi.selenium.util.PageNavigation.java

protected void returnAccountsPage() {
    try {/* ww w . j ava 2  s. co  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 clickOnRadio10() {
    try {/*from w  ww.j av a2  s . com*/
        // 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[2]/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 clickOnRadio30() {

    try {//from   ww  w  .  ja  v  a2s  .  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 clickOnRadio50() {
    try {/*from w  w  w. j a va2  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[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 clickOnRadio100() {
    try {/* w  w  w . j a v a2s .  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[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 void clickOnRadioRM10() {
    try {//from   w  ww  .j a va2 s .  c om

        // 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[2]/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 clickCancel() {
    try {//from  w w  w .j ava 2  s.co  m
        //*[@id='pay-getaway-foot']/div[2]/form/button[3]
        WebElement cancel = (new WebDriverWait(driver, 1000)).until(ExpectedConditions
                .elementToBeClickable(By.xpath("//*[@id='pay-getaway-foot']/div[2]/form/button[3]")));
        cancel.click();
        Thread.sleep(500);
        //System.out.println("Cancel is clicked now accepting alert box");
        driver.switchTo().alert().accept();

        waitForPageLoad(100);
        Thread.sleep(500);
        Set<String> windows = getDriver().getWindowHandles();
        Iterator<String> winitr = windows.iterator();
        String mainwinid = winitr.next();
        String popupwinid = winitr.next();
        driver.switchTo().window(popupwinid);
        WebElement cancelpopup = getDriver().findElement(By.xpath("//*[@id='dsy_frameholder']/a"));
        cancelpopup.click();
        waitForPageLoad(100);
        Thread.sleep(500);
    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        log.error("Fail : Failed to Reload amount.");
        System.exit(0);
    }
}