Skip to content
Advertisement

Select first row after table is populated

I have this Angular SPA app which is displaying table rows after search:

JavaScript

Do you know how I can implement a listener with Java and Selenium which waits for table row to be displayed and clicks in it? I tried something like this:

JavaScript

But it’s not working. Can you guide me for appropriate solution?

Advertisement

Answer

Basically if you pay attention, you would see that this table is not build using tr and td tags. Basically it is a div with attribute role="row"

Also, to answer this part

JavaScript

we have 2 ways.

  1. Use findElements onto that particular web element.

  2. Use Explicit waits.

Code with Explicit waits :

This xpath //div[@role='row'][@row-index='0']/div matches 4 nodes in HTML DOM. But since you’ve mentioned that you wanna, target and click on 6673718, using the mentioned xpath it would click on the first element and that represent the 6673718

JavaScript

Code with FindElements :

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement