3

Using selenium IDE- I am looking for a way to locate and or verify a value in a table. There are more columns in the table, but I am only concerned with the first 4. Also the number of rows varies as well as the location of the value I am looking for.

So, say, I am looking for username there. the username = “fred”, who could exist in any row 1 to 10.
How could I locate and verify that user exist?
enter image description here

  • 2
    Please post your HTML-Code as code not as image – bish Oct 27 '15 at 4:43
  • yes actual code so we can copy and paste when makin our answers please – Michael Durrant Mar 25 '16 at 15:57
1

Personally the best way I have found is to loop through the table rows, then get the text from the you need to and compare. Below I have an example of what you can use, it should be easy enough to change to your liking.

public boolean searchUsername(WebDriver driver, String username){
    boolean isFound = false;
    List<WebElement> rows = driver.findElements(By.cssSelector("tbody > tr"));
    for(WebElement row : rows){
        if(row.findElement(By.cssSelector("td:nth-of-type(2)").getText.equals(username){
            isFound = true;
            break;
        }
    }
    return isFound;
}
0

It is two different task in selenium IDE.

  1. Create loop in selenium. Dig this link

  2. Apply table data finding logic. Link can help you

0

Maybe do

assertText
table td(3).text
='fred'

Will look in all the column 3 values

0

You can loop through the tds of table.

You need to first capture the table id or the div under which table is located. then using this element you have to loop through all td and check td's text == "fred".

0

Verifytext can be used to verify text exist within the table. enter image description here

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.