How to Iterate nested div element using selenium script


#1

Hi,
Can anyone tell me how to iterate nested div elements using selenium automation and nested div elements contains some other tags also like span tag…can anyone have idea about this…Please share some ideas about this…
Thanks
Sharad Kumar


#2

Hi @sharad_kumar ,

can you please clarify if the problem is related to RPA Express? If yes, we will need a more detailed description and the page html code.

-Nataliya


#3

Hi,
Yes it is related to rpa…I am automating business process inside tags using selenium automation…There i found some nested tags like this…

Some Value

Some Value

Some Value

Some Value

Some Value

Some Value

Here I want to iterate over nested div tag and i want to take span value always…if in future more div tag will come that also it can iterate…Based on span value i want to do some business process like open spread sheet and save the span value…Can you help me this how we can achieve this?Can you take current rpa this page nested div elements using inspect elements .
Thanks
Sharad Kumar


#4

@sharad_kumar,

Please post here the page source code and explain your task in more details.

Your recording folder with test example and a video recording if your actions will help us understand you better. Thanks!


#5

Hi @sharad_kumar,

Could you please share page source code and explain your task in more details?
Your recording folder with test example and a video recording of your action will be very useful.

Best regards,
Yuliya


archived #6

#7

Continuing the discussion from How to Iterate nested div element using selenium script:

<...several nested tags...>
<...several nested tags.../>
<...several nested tags...>
<...several nested tags.../>
<...several nested tags...>
<...several nested tags.../>

#8

@sharad_kumar - it is not clear from your description what you want to achieve.

Please post real html code and describe what you want to do with recorder - which info to extract or click.

Some screenshots will also help


unarchived #9

#10

Hi @azinchuk
i want to iterate this child tags…In child div tags may be one span tag i want to get span tag value genrically here you can consider parent tag is div inside div there is lot of div tags like in this screen shot
image
Thanks
Sharad Kumar


#11

@sharad_kumar,

The approach is the same as here - Looping multiple buttons in dynamic webpage

Your XPath will be some thing like this:

//div[@class='graph']/*/div[@class='parent']/div/span

And you will iterate trough a list using the following expression:

//div[@class='graph'][${iterator}]/*/div[@class='parent']/div/span

#12

Thanks @azinchuk