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.epam.jdi.uitests.mobile.appium.elements.complex.Elements.java

License:Open Source License

protected boolean getElementByNameAction(WebElement element, String name) {
    return element.getText().equals(name);
}

From source file:com.epam.jdi.uitests.mobile.appium.elements.complex.Selector.java

License:Open Source License

private String getSelected(List<WebElement> els) {
    WebElement element = first(els, this::isSelectedAction);
    if (element == null)
        throw exception("No elements selected. Override getSelectedAction or place locator to <select> tag");
    return element.getText();
}

From source file:com.epam.jdi.uitests.mobile.appium.elements.complex.TextList.java

License:Open Source License

protected String getTextAction(WebElement element) {
    return element.getText();
}

From source file:com.epam.jdi.uitests.web.selenium.elements.common.Text.java

License:Open Source License

protected String getTextAction() {
    WebElement element = getWebElement();
    String getValue = element.getAttribute("value");
    if (getValue != null && !getValue.equals(""))
        return getValue;
    String getText = element.getText();
    return getText != null ? getText : getValue;
}

From source file:com.epam.jdi.uitests.web.selenium.elements.complex.Selector.java

License:Open Source License

private String getSelected(List<WebElement> els) {
    WebElement element = first(els, this::isSelectedAction);
    if (element == null)
        throw exception("No elements selected. Override getSelectedAction or place locator to <select> tag");
    new Element(element).invoker.processDemoMode();
    return element.getText();
}

From source file:com.etouch.cisco.common.CiscoMainPage.java

public void ValidECU(TestParameters input) throws InterruptedException {
    final int MAX_WAIT = 50;
    String tempecu = "";
    try {//from  w  w  w.j  a v a 2 s  . c o m
        //SignIn(input);
        jsx.executeScript("window.document.getElementById('newCalculation').click()");
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements.ServerCount_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE))
                        .enterText(input.getParamMap().get("servercount"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements.CPUCount_XPATH, ObjectValType.XPATH,
                MAX_WAIT, WaitCondition.VISIBLE)).enterText(input.getParamMap().get("cpucount"));

        // testing kanika - start
        WebElement table = webDriver.findElement(By.id(MainPageElements.TotalECU_ID));
        List<WebElement> allRows = table.findElements(By.tagName("tr"));
        for (WebElement row : allRows) {
            List<WebElement> cells = row.findElements(By.tagName("td"));
            for (WebElement colElement : cells) {
                tempecu = colElement.getText();
            }
        }
        totalECU = Float.parseFloat(tempecu);
        // testing kanika - end
        ((SelectBox) webPage.findObject(ObjectType.SelectBox, "selectCpu", ObjectValType.ID, MAX_WAIT,
                WaitCondition.VISIBLE)).selectDropDownList("E5-2650 v2");
        // jsx.executeScript("document.getElementById('calculate').click()");
        //////webPage.sleep(100);
    } catch (Exception e) {
        log.error(getErrMessage());
        System.err.println(getErrMessage());
    }
}

From source file:com.example.getstarted.basicactions.UserJourneyTestIT.java

License:Apache License

private WebElement checkLandingPage() throws Exception {
    WebElement button = driver.findElement(By.cssSelector("a.btn"));
    assertEquals("Add book", button.getText());

    WebElement heading = driver.findElement(By.cssSelector("body>.container h3"));
    assertEquals("Books", heading.getText());

    WebElement list = driver.findElement(By.cssSelector("body>.container p"));
    assertEquals("No books found", list.getText());

    WebElement loginButton = driver.findElement(By.linkText("Login"));
    assertTrue(null != loginButton);//from   w  w w.java2 s .c om

    return button;
}

From source file:com.example.getstarted.basicactions.UserJourneyTestIT.java

License:Apache License

private WebElement checkLandingPage(String email) throws Exception {
    WebElement logout = driver.findElement(By.linkText(email));
    assertTrue(null != logout);/*ww w . j  a v a2 s. co m*/

    WebElement button = driver.findElement(By.cssSelector("a.btn"));
    assertEquals("Add book", button.getText().trim());

    WebElement heading = driver.findElement(By.cssSelector("body>.container h3"));
    assertEquals("Books", heading.getText());

    WebElement list = driver.findElement(By.cssSelector("body>.container p"));
    assertEquals("No books found", list.getText());

    return button;
}

From source file:com.example.getstarted.basicactions.UserJourneyTestIT.java

License:Apache License

private void checkReadPage(String title, String author, String datePublished, String description,
        String addedBy) throws Exception {
    WebElement heading = driver.findElement(By.cssSelector("h3"));
    assertEquals("Book", heading.getText());

    List<WebElement> buttons = driver.findElements(By.cssSelector("a.btn"));
    assertEquals(2, buttons.size());//  w  w  w.  j a va 2 s  .  c  o m
    assertEquals("Edit book", buttons.get(0).getText());
    assertEquals("Delete book", buttons.get(1).getText());

    // Should be a cat thumbnail
    assertTrue(driver.findElement(By.cssSelector("img.book-image")).getAttribute("src")
            .indexOf("placekitten") > 0);
    assertTrue("Should show title",
            driver.findElement(By.cssSelector(".book-title")).getText().startsWith(title));
    assertEquals("Should show author", "By " + author,
            driver.findElement(By.cssSelector(".book-author")).getText());
    assertEquals("Should show description", description,
            driver.findElement(By.cssSelector(".book-description")).getText());

    assertTrue(driver.findElement(By.cssSelector(".book-added-by")).getText().indexOf(addedBy) > 0);
}

From source file:com.example.selenium.find.elements.FindElementXPath.java

@Test
public void findByAttibutes() {
    WebElement element = driver.findElement(By.xpath("//button[@type='submit']"));
    System.out.println("Element Value =" + element.getText());
}