Reputation: 2334
I am having one webtable with class name as MessageTable and having the below list item inside the table data(td)
<td>
<ul class="error">
<li class="ng-binding ng-scope" ng-repeat="error in errors">Validation1</li>
<li class="ng-binding ng-scope" ng-repeat="error in errors">Validation2</li>
<li class="ng-binding ng-scope" ng-repeat="error in errors">Validation3</li>
</ul>
</td>
I need to read all the above content (Validation1,Validation2,Validation3) from web page and need to validate against the expected validation Message.
Upvotes: 0
Views: 2913
Reputation: 2334
I have found the solution for the above question. Please find the working steps
WebElement table = driver.findElement(By.className("messageTable"));
List<WebElement> rows = table.findElements(By.tagName("li"));
for(WebElement element:rows ){
System.out.println(element.getText());
}
Upvotes: 0
Reputation: 3004
I assume that class="ng-binding ng-scope" ng-repeat="error in errors"
only appears in your table.
Try this:
List<WebElement> elems= driver.findElements(By.cssSelector("li.ng-binding.ng-scope[ng-repeat$='errors']"));
for(WebElement element:elems ){
if(element.getText().equals("ur validation message")){
//do something as ur wish.
}
}
Upvotes: 1