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.easytox.automation.steps.LabClientImpl.java

@When("^Click on the Edit Icon$")
public void click_on_the_edit_icon() {
    WebElement el = MyWebDriverUtils.findElement(driver, EDIT_LIST_PAGE_ICON_LOCATOR, LocatorType.CSS);
    WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS);

    boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID);
    if (flag) {// w ww .  j  av a  2  s  .  c  o m
        checkAndClick(el);
    } else {
        Assert.fail("flag is false!");
    }
}

From source file:com.easytox.automation.steps.LabClientImpl.java

@When("^Make changes to Personal Information and click update$")
public void make_changes_to_personal_information_and_click_update() {
    WebElement firstName = MyWebDriverUtils.findElement(driver, USER_FIRST_NAME_LOCATOR, LocatorType.CSS);
    if (firstName != null) {
        firstName.clear();//from   ww w .  ja  v  a 2  s . c o m
        firstName.sendKeys(USER_FIRST_NAME_VALUE);
    } else {
        Assert.fail("firstName is null!");
    }

    WebElement lastName = MyWebDriverUtils.findElement(driver, USER_LAST_NAME_LOCATOR, LocatorType.CSS);
    if (lastName != null) {
        lastName.clear();
        lastName.sendKeys(USER_LAST_NAME_VALUE);
    } else {
        Assert.fail("lastName is null!");
    }

    WebElement email = MyWebDriverUtils.findElement(driver, USER_EMAIL_LOCATOR, LocatorType.NAME);
    if (email != null) {
        email.clear();
        email.sendKeys(USER_EMAIL_VALUE);
    } else {
        Assert.fail("email is null!");
    }

    WebElement phoneNumber = MyWebDriverUtils.findElement(driver, USER_PHONE_NUMBER_LOCATOR, LocatorType.NAME);
    if (phoneNumber != null) {
        phoneNumber.clear();
        phoneNumber.sendKeys(USER_PHONE_NUMBER_VALUE);
    } else {
        Assert.fail("phoneNumber is null!");
    }

    new Select(driver.findElement(By.id(LAB_LOCATIONS_LOCATOR))).selectByVisibleText(LAB_LOCATIONS_VALUE);

    WebElement el = MyWebDriverUtils.findElement(driver, UPDATE_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(el);
    } else {
        Assert.fail("flag is false!");
    }

}

From source file:com.easytox.automation.steps.LabClientImpl.java

@When("^Click '\\+' icon against newly created user$")
public void click_plus_icon_against_newly_created_user() {
    WebElement el = MyWebDriverUtils.findElement(driver, PLUS_ICON_LOCATOR, LocatorType.CSS);
    WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS);

    boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID);
    if (flag) {/*from  www  . j  ava 2  s  .c om*/
        checkAndClick(el);
    } else {
        Assert.fail("flag is false!");
    }
}

From source file:com.easytox.automation.steps.LabClientImpl.java

@When("^Click 'Lock' icon for any existing user$")
public void click_lock_icon_for_any_existing_user() {
    WebElement lock = MyWebDriverUtils.findElement(driver, LOCK_LOCATOR, LocatorType.CSS);
    if (lock != null && lock.getAttribute(ATTRIBUTE_CLASS_LOCATOR).equals(LOCK_VALUE)) {
        WebElement el = MyWebDriverUtils.findElement(driver, LOCK_ICON_LOCATOR, LocatorType.CSS);
        WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS);

        boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID);
        if (flag) {
            checkAndClick(el);//from ww w  .  j av  a2  s  .co  m
        } else {
            Assert.fail("flag is false!");
        }
    }
    WebElement el = MyWebDriverUtils.findElement(driver, LOCK_ICON_LOCATOR, LocatorType.CSS);
    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!");
    }
}

From source file:com.easytox.automation.steps.LabClientImpl.java

@When("^Logout and attempt logging in with the above lab user credentials$")
public void logout_and_attempt_logging() {
    WebElement el = MyWebDriverUtils.findElement(driver, FIRST_CGI_LAST_CGI_LOCATOR, LocatorType.CSS);
    WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS);

    boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID);
    if (flag) {//  w ww  .j a  va 2s  .c  o m
        checkAndClick(el);
    } else {
        Assert.fail("flag is false!");
    }

    WebElement el1 = MyWebDriverUtils.findElement(driver, SIGN_OUT_LOCATOR, LocatorType.CSS);
    WebDriverWait wait1 = new WebDriverWait(driver, TIME_OUT_IN_SECONDS);

    boolean flag1 = MyWebDriverUtils.waitInvisibilityOfElement(wait1, CONTAINER_LOCATOR, LocatorType.ID);
    if (flag1) {
        checkAndClick(el1);
    } else {
        Assert.fail("flag is false!");
    }
}

From source file:com.easytox.automation.steps.LabClientImpl.java

@When("^Click on the Add Notes Icon$")
public void click_on_the_add_notes_icon() {
    WebElement el = MyWebDriverUtils.findElement(driver, ADD_NOTES_ICON_LOCATOR, LocatorType.CSS);
    WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS);

    boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID);
    if (flag) {/*from ww w . j a va2s  .  c  o m*/
        checkAndClick(el);
    } else {
        Assert.fail("flag is false!");
    }
}

From source file:com.easytox.automation.steps.LabClientImpl.java

@When("^Click '\\+' icon and add note. By clicking on '\\+' sign multiple times, multiple notes can be added.Click Update Notes$")
public void click_plus_icon_and_add_note() {
    for (int i = 0; i < 3; i++) {
        WebElement el = MyWebDriverUtils.findElement(driver, NOTES_PLUS_ICON_LOCATOR, LocatorType.CSS);
        WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS);

        boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID);
        if (flag) {
            checkAndClick(el);/*ww  w .  j  av  a2  s  . com*/
        } else {
            Assert.fail("flag is false!");
        }

        List<WebElement> notes = MyWebDriverUtils.findElements(driver, NEW_NOTE_LOCATOR, LocatorType.ID);
        if (notes != null) {
            notes.get(i).clear();
            notes.get(i).sendKeys(NEW_NOTE_VALUE + i);
        } else {
            Assert.fail("notes is null!");
        }
    }

    WebElement button = MyWebDriverUtils.findElement(driver, UPDATE_NOTES_BUTTON_LOCATOR, LocatorType.CSS);
    WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS);

    boolean flag1 = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID);
    if (flag1) {
        checkAndClick(button);
    } else {
        Assert.fail("flag is false!");
    }

}

From source file:com.easytox.automation.steps.LabClientImpl.java

@When("^Click 'Edit' icon against the newly added note$")
public void click_edit_icon() {
    WebElement button = MyWebDriverUtils.findElement(driver, ICON_NOTES_LOCATOR, LocatorType.CSS);
    WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS);

    boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID);
    if (flag) {// www  . j  a va 2 s .  com
        checkAndClick(button);
    } else {
        Assert.fail("flag is false!");
    }
}

From source file:com.easytox.automation.steps.LabClientImpl.java

@When("^Click on the Clinician List icon for a Lab Client$")
public void click_on_the_clinician_list_icon_for_a_lab_client() {
    WebElement icon = MyWebDriverUtils.findElement(driver, CLINICIAN_ICON_LOCATOR, LocatorType.CSS);
    WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS);

    boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID);
    if (flag) {//from   ww  w  .  j a  va  2  s .  c o m
        checkAndClick(icon);
    } else {
        Assert.fail("flag is false!");
    }
}

From source file:com.easytox.automation.steps.LabClientImpl.java

@When("^Click on the '\\+' Icon$")
public void click_on_the_plus_icon() {
    WebElement plusButton = MyWebDriverUtils.findElement(driver, ADD_PHYSICIAN_LOCATOR, LocatorType.CSS);
    WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS);

    boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID);
    if (flag) {/*w w w.  j  a  v  a 2  s  .  co  m*/
        checkAndClick(plusButton);
    } else {
        Assert.fail("flag is false!");
    }
}