Example usage for org.openqa.selenium WebElement getText

List of usage examples for org.openqa.selenium WebElement getText

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement getText.

Prototype

String getText();

Source Link

Document

Get the visible (i.e.

Usage

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

@Then("^User should be locked and 'User locked successfully' message should be populated$")
public void user_should_be_locked() {
    WebElement widget = MyWebDriverUtils.findPresenceElement(driver, SUCCESS_LOCATOR, LocatorType.CSS);
    if (widget != null) {
        String title = widget.getText();
        Assert.assertEquals(title, SUCCESS_VALUE);
    }//from   ww w.jav  a 2 s.  c om

    WebElement el = MyWebDriverUtils.findElement(driver, MESSAGE_LOCATOR, LocatorType.CSS);
    if (el != null) {
        Assert.assertEquals(el.getText(), MESSAGE_VALUE);
    }

    WebElement lock = MyWebDriverUtils.findElement(driver, LOCK_LOCATOR, LocatorType.CSS);
    if (lock != null) {
        Assert.assertEquals(lock.getAttribute(ATTRIBUTE_CLASS_LOCATOR), LOCK_VALUE);
    }

}

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

@Then("^Update Lab Client Notes page should be displayed$")
public void update_lab_client_notes_page_should_be_displayed() {
    String currentUrl = driver.getCurrentUrl();
    Assert.assertEquals(currentUrl, UPDATE_LAB_CLIENTS_NOTES_URL);

    WebElement widget = MyWebDriverUtils.findPresenceElement(driver, WIDGET_ADD_LOCATOR, LocatorType.CSS);
    if (widget != null) {
        String title = widget.getText();
        Assert.assertEquals(title, WIDGET_UPDATE_NOTES_VALUE);
    }//from   ww  w .j a v a2s .  c  o m
}

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

@Then("^Notes for lab client should be saved successfully along with date stamp$")
public void check_saved_notes() {
    String currentUrl = driver.getCurrentUrl();
    Assert.assertEquals(currentUrl, UPDATE_NOTES_URL);

    WebElement widget = MyWebDriverUtils.findPresenceElement(driver, MESSAGE_LOCATOR, LocatorType.CSS);
    if (widget != null) {
        String title = widget.getText();
        Assert.assertEquals(title, NOTES_ALERT_VALUE);
    }/*from  w  w  w  .  j  ava 2  s .  com*/

    for (int i = 0; i < 3; i++) {
        boolean flag = false;
        WebElement note = MyWebDriverUtils.findElement(driver, NEW_NOTE_LOCATOR + "[" + i + "]",
                LocatorType.ID);
        if (note != null) {
            String noteValue = note.getAttribute(ATTRIBUTE_VALUE_LOCATOR);
            if (noteValue.equals(NEW_NOTE_VALUE + 0) || noteValue.equals(NEW_NOTE_VALUE + 1)
                    || noteValue.equals(NEW_NOTE_VALUE + 2)) {
                flag = true;
            }
            Assert.assertTrue(flag);
        } else {
            Assert.fail("notes is null!");
        }
    }

    WebElement el = MyWebDriverUtils.findElement(driver, "#clientNoteDiv > div > label", LocatorType.CSS);
    if (el != null) {
        String user = el.getText();
        Assert.assertNotNull(user);
        Assert.assertTrue(user.contains("cgilabadmin"));
    } else {
        Assert.fail("el is null!");
    }

}

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

@Then("^Clinician List page should be displayed$")
public void clinician_list_page_should_be_displayed() {
    String currentUrl = driver.getCurrentUrl();
    Assert.assertEquals(currentUrl, CLINICIAN_LIST_URL);

    WebElement widget = MyWebDriverUtils.findPresenceElement(driver, WIDGET_LAB_LOCATION_LIST_LOCATOR,
            LocatorType.CSS);/*from   w w  w .j  a v  a 2  s . c om*/
    if (widget != null) {
        String title = widget.getText();
        Assert.assertEquals(title, WIDGET_CLINITIAN_LIST_VALUE);
    }
}

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

@Then("^Add Physician screen is displayed$")
public void add_physician_screen_is_displayed() {
    String currentUrl = driver.getCurrentUrl();
    Assert.assertEquals(currentUrl, ADD_PHYSICIAN_URL);

    WebElement widget = MyWebDriverUtils.findPresenceElement(driver, WIDGET_ADD_LOCATOR, LocatorType.CSS);
    if (widget != null) {
        String title = widget.getText();
        Assert.assertEquals(title, ADD_PHYSICIAN_VALUE);
    }/* w  w w .  ja  v a 2  s . c  o m*/
}

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

@Then("^Clinician should be added successfully$")
public void clinician_should_be_added_successfully() {
    String currentUrl = driver.getCurrentUrl();
    Assert.assertEquals(currentUrl, "http://bmtechsol.com:8080/easytox/clinician/clinicianlist");

    WebElement widget = MyWebDriverUtils.findPresenceElement(driver,
            "#maincontentdiv > div.page-body > div.alert.alert-success.fade.in > strong", LocatorType.CSS);
    if (widget != null) {
        String title = widget.getText();
        Assert.assertEquals(title, SUCCESS_VALUE);
    }//from w  w  w  .java 2 s.  c  o  m
}

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

@Then("^Default number '10' should be displayed in the dropdown box$")
public void check_default_value() {
    for (WebElement option : selectOptions) {
        Assert.assertEquals(option.getText(), DEFAULT_NUMBER_OF_RECORDS);
    }//from ww w. java2  s .com
}

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

@Then("^A text message 'Showing x to y of z entries' should be displayed on the bottom left corner of the list$")
public void message_should_be_displayed() {
    WebElement el = MyWebDriverUtils.findElement(driver, "#example_info", LocatorType.CSS);
    if (el != null) {
        String message = el.getText();
        Assert.assertTrue(message.contains("Showing"));
        Assert.assertTrue(message.contains("to"));
        Assert.assertTrue(message.contains("of"));
        Assert.assertTrue(message.contains("entries"));
    }/*from   w w  w  . ja  va2s. c o m*/
}

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

@Then("^Changes should be reflected appropriately$")
public void changes_should_be_reflected_appropriately() {
    try {/*from   ww  w. j  a  v  a2  s . c  o  m*/
        List<WebElement> listCells = MyWebDriverUtils.getCells(driver, TABLE_LOCATOR, LocatorType.ID, 1, 8);
        if (listCells != null) {
            MyWebDriverUtils.checkCurrentUrl(driver, PHYSICIAN_LIST_URL);
            WebElement element = MyWebDriverUtils.findPresenceElement(driver, SUCCESS_UPDATE_LOCATOR,
                    LocatorType.CSS);
            if (element != null) {
                Assert.assertEquals(element.getText(), SUCCESS_UPDATE_MESSAGE);
            } else {
                Assert.fail("element is null!");
            }
            Assert.assertEquals(listCells.get(4).getText(), Physician.SALUTATION);
            Assert.assertEquals(listCells.get(5).getText(), Physician.MEDICARE_NUMBER);
            Assert.assertEquals(listCells.get(6).getText(), Physician.MEDICAID_NUMBER);
        } else {
            throw new StaleElementReferenceException("listCells is null!");
        }
    } catch (StaleElementReferenceException ex) {
        changes_should_be_reflected_appropriately();
    }
}

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

@Then("^Default num '10' should be displayed in the dropdown box$")
public void default_num_10_should_be_displayed_in_he_dropdown_box() {
    for (WebElement option : selectOptions) {
        Assert.assertEquals(option.getText(), DEFAULT_NUMBER_OF_RECORDS);
    }//from w w w . ja  va2s.  c  om
}