Search in sources :

Example 1 with TableNotContainTextError

use of ru.sbtqa.tag.pagefactory.exception.TableNotContainTextError in project page-factory-2 by sbtqa.

the class TableAbstract method getRowAsCells.

private WebElement getRowAsCells(WebElement context, int columnIndex, String cellText) {
    String searchFragment = getSearchFragment(cellText, SearchStrategy.EQUALS);
    List<WebElement> cells = context.findElements(By.xpath(getColumnXpath(columnIndex) + searchFragment));
    try {
        WebElement cell = ElementUtils.getElementByIndex(cells, 0);
        if (isSimpleCell(cell)) {
            LOG.warn("Cell text is complex. A match was found among one of the cell elements");
        }
        return cell;
    } catch (ElementNotFoundException ex) {
        throw new TableNotContainTextError(cellText);
    }
}
Also used : ElementNotFoundException(ru.sbtqa.tag.pagefactory.exceptions.ElementNotFoundException) TableNotContainTextError(ru.sbtqa.tag.pagefactory.exception.TableNotContainTextError) WebElement(org.openqa.selenium.WebElement)

Example 2 with TableNotContainTextError

use of ru.sbtqa.tag.pagefactory.exception.TableNotContainTextError in project page-factory-2 by sbtqa.

the class TableAbstract method selectRow.

private void selectRow(WebElement context, String cellText, SearchStrategy searchStrategy, int serialNumber, boolean doubleClick) {
    String searchFragment = getSearchFragment(cellText, searchStrategy);
    List<WebElement> cells = context.findElements(By.xpath(getColumnsXpath() + searchFragment));
    try {
        WebElement cell = ElementUtils.getElementByIndex(cells, serialNumber - 1);
        if (isSimpleCell(cell)) {
            LOG.warn("Cell text is complex. A match was found among one of the cell elements");
        }
        click(cell, doubleClick);
    } catch (ElementNotFoundException ex) {
        throw new TableNotContainTextError(cellText);
    }
}
Also used : ElementNotFoundException(ru.sbtqa.tag.pagefactory.exceptions.ElementNotFoundException) TableNotContainTextError(ru.sbtqa.tag.pagefactory.exception.TableNotContainTextError) WebElement(org.openqa.selenium.WebElement)

Aggregations

WebElement (org.openqa.selenium.WebElement)2 TableNotContainTextError (ru.sbtqa.tag.pagefactory.exception.TableNotContainTextError)2 ElementNotFoundException (ru.sbtqa.tag.pagefactory.exceptions.ElementNotFoundException)2