Skip to content
Advertisement

Selenium Issue When Having tabular data in the form of DIV on a website where inside a DIV I have one div for every row

While writing Selenium automation test for a website having number of rows in the form of DIV inside one DIV. every row denotes one DIV. suppose dynamically if I have 5 rows then following code structure is there.

JavaScript

I am fetching each row div/table/tr/td using XPath in for loop in my code and clicking on each. So that I can download pdf. But it is working fine for 19 DIV. for 20th DIV I am not able to find that in my page using XPATH. I am getting no such element exception. though I applied wait then I get that explicit condition failed issue. Can anyone having idea that its a scroll issue or anything else because of which I am not able to fine 20th and further more divs.

Advertisement

Answer

Probably it looks like that element is not in Selenium viewPort.

You have multiple ways to deal with this :

1. Scrolling :

JavaScript

This is not very optimal way. Now, You can try for each element scroll to view :

2. scrollIntoView :

Let’s say you have a list of web elements. (allDivs)

JavaScript

3. Use of moveToElement

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