Example usage for org.openqa.selenium By xpath

List of usage examples for org.openqa.selenium By xpath

Introduction

In this page you can find the example usage for org.openqa.selenium By xpath.

Prototype

public static By xpath(String xpathExpression) 

Source Link

Usage

From source file:be.rubus.web.testing.CommonElementCode.java

License:Apache License

protected List<WebElement> getAllChildren(WebElement element) {
    return element.findElements(By.xpath("*"));
}

From source file:beseenium.model.action.findElementsBy.FindElementsByXpath.java

License:Open Source License

/**
 * performs the find elements by xpath action
 * @param n the index of the element to find information on, i.e. if 3 results are found
 * the 0 will be the first element 1 the second and so on. will get an array out of bounds.
 * If you wish the action to return all of the results found then set n = -1.
 * @return String representation of the returnParam set in the ActionData object
 * passed into the constructor.//from  w  w w . j  a  v a  2 s.c om
 * @throws ActionDataException  
 */
@Override
public String execute(int n) throws ActionDataException {
    String searchParam = super.context.getInputParam();
    WebDriver browser = super.context.getDriver();
    List<WebElement> htmlElements = browser.findElements(By.xpath(searchParam));

    super.context.setElement(htmlElements);

    return FormatOutput.formatFindElementOutput(htmlElements, n);
}

From source file:bi.meteorite.pages.SaikuTable.java

License:Apache License

public List<WebElement> headingElements() {
    return tableElement.findElements(By.xpath(".//th"));
}

From source file:bi.meteorite.pages.SaikuTable.java

License:Apache License

public List<WebElement> firstRowElements() {
    return tableElement.findElement(By.tagName("tr")).findElements(By.xpath(".//td"));
}

From source file:bi.meteorite.pages.SaikuTable.java

License:Apache License

public List<WebElement> getRowElementsFor(List<String> headings) {

    List<WebElement> rowCandidates = tableElement
            .findElements(By.xpath(".//tr[th][count(th|td)>=" + headings.size() + "]"));
    //rowCandidates = stripHeaderRowIfPresent(rowCandidates, headings);
    return rowCandidates;
}

From source file:bi.meteorite.pages.SaikuTable.java

License:Apache License

private boolean hasMatchingCellValuesIn(WebElement firstRow, List<String> headings) {
    String html = firstRow.getAttribute("innerHTML");
    List<WebElement> cells = firstRow.findElements(By.xpath("//td | //th"));
    for (int cellIndex = 0; cellIndex < headings.size(); cellIndex++) {
        if ((cells.size() < cellIndex) || (!cells.get(cellIndex).getText().equals(headings.get(cellIndex)))) {
            return false;
        }/*  ww  w.  ja  v  a 2  s  .c om*/
    }
    return true;
}

From source file:bi.meteorite.pages.SaikuTable.java

License:Apache License

private List<WebElement> cellsIn(WebElement row) {
    return row.findElements(By.xpath("./td | ./th"));
}

From source file:bodega.test.selenium.BodegaTest.java

@Test
public void testCrearBodega() throws Exception {
    webDriver.findElement(By.xpath("//button[contains(@id, 'createButton')]")).click();
    Thread.sleep(2000);/*from  ww w. j  a  v a  2  s.  c  o  m*/

    webDriver.findElement(By.id("name")).clear();
    webDriver.findElement(By.id("name")).sendKeys("NuevaBodega");

    webDriver.findElement(By.xpath("//button[contains(@id, 'saveButton')]")).click();
    Thread.sleep(2000);
    List<WebElement> table = webDriver
            .findElements(By.xpath("//table[contains(@class,'table striped')]/tbody/tr"));
    boolean good = false;
    for (WebElement webElement : table) {
        List<WebElement> elements = webElement.findElements(By.xpath("td"));
        for (WebElement elemento : elements) {
            if (elemento.getText().equals("NuevaBodega"))
                good = true;
        }
    }

    assertTrue(good);
}

From source file:br.com.esign.logistics.test.selenium.page.HomePage.java

License:Open Source License

public void selectMap(String map) {
    WebElement mapAccordion = driver//from w w w.java 2  s. co m
            .findElement(By.xpath("//a[@class='accordion-toggle']/span[text()='" + map + "']"));
    waitForElement(mapAccordion);
    mapAccordion.click();
}

From source file:br.eti.kinoshita.selenium.samples.GoogleMainPage.java

License:Open Source License

public void searchFor(String searchQuery) {
    searchQueryField.sendKeys(searchQuery);

    searchButton.submit();// w  w w.  ja va 2s.  c o  m

    wait.until(Utils.presenceOfElement(By.xpath("//h3[@class='r']//a")));
}