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

Bharat Mane
6,78512 gold badges42 silver badges69 bronze badges
asked Oct 27, 2015 at 1:16
2
  • 2
    Please post your HTML-Code as code not as image Commented Oct 27, 2015 at 4:43
  • yes actual code so we can copy and paste when makin our answers please Commented Mar 25, 2016 at 15:57

5 Answers 5

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;
}
answered Mar 14, 2017 at 16:32
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

answered Oct 27, 2015 at 6:59
0

Maybe do

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

Will look in all the column 3 values

answered Mar 25, 2016 at 15:54
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".

answered Nov 14, 2016 at 8:44
0

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

enter image description here

enter image description here

answered Apr 10, 2017 at 6:40

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.