I have react generated web page which has this kind of structure:
div
...
div
div
div class=x_1
<span randomtag=y> text1 </span>
div class=x
<span randomtag=z> text2 </span>
div class=x
<span randomtag=q> text3 </span>
div
div
div
...
div
I am trying to click on the randomtag=z. I have tried:
xpath:
- I can find the randomtag y's div with just tossing in the structure up to the div (no other identificators) with .../div[2]/div[1]
- I can NOT get the second div with xpath (.../div[2]/div[1] works but .../div[2]/div[2] does not work)
css:
The following is not working either
css=div > span[randomtag="z"]
css=div.x span[randomtag="z"]
I am a bit lost with the possibilities here to select the correct element.
The Robot code is just basic wait until element is visible | locator (whatever it is) eg.
wait until element is visible css=div.x span[randomtag="z"]
wait until element is visible xpath=<previous path here>/div[2]/div[2]
Any ideas? Is the react reason for this?
I get "Element not visible in x seconds". For timeout I have tried 5-30 seconds.
EDIT:
I also tried to find the xpath with the search tool (behind dev tools on browser) and it finds the element when I insert either the xpath or css locator to the search.
div of randomtag = 'y'
with elementz
? – Paras//span[@randomtag='z']/..
it will give you the parent div ofrandomtag = z
– Paras