I have a table with data. I need to check that table contains some data and does not contain any other data. So I need to check that table contains entries equal to some unique value.
I solved that task in two steps:
The first step is using XPath
function contains()
which check that table contains interesting elements.
Second step checks that table does not have other elements which are not equal search value by using XPath
not contains()
function.
Example:
List <WebElement> rows = tableBody.findElements(By.xpath("//*[not(contains(td,"+ elementName + "))]"));
This solution is not good, because not contains()
function runs twice longer.
Is there other solution how to check that table has elements with search pattern and contains only them?