How to access the nested html which is within a frame through Selenium [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to access the nested html which is within a frame through Selenium [duplicate]



This question already has an answer here:



I have a website where a html tag is nested inside like below.
Questions:



Please help. Thanks.
Please get the application source code from this link.



enter image description here



This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





I tried with this driver.switchTo().frame("frameBody"); but it causes No frame element found by name or id frameBody.
– peterwkc
Aug 13 at 5:44




1 Answer
1



The <frame> with id = frameBody is nested in another <iframe>, you need to switch to it first


<frame>


id = frameBody


<iframe>


WebElement iframe = driver.findElement(By.cssSelector("#tabFrames > iframe:nth-child(1)"));
driver.switchTo().frame(iframe);
driver.switchTo().frame("frameBody");





Please see my screenshot of code. Can you pin point me the exact structure?
– peterwkc
Aug 13 at 6:55





@peterwkc The structure is very clear, you can see it by the indentations. You can also open and close sections in the developer tools to see it.
– Guy
Aug 13 at 6:58





It throws NoSuchElementException: no such element: Unable to locate element: tabFrames > iframe:nth-child(2)
– peterwkc
Aug 13 at 7:11






@peterwkc It should be driver.findElement(By.cssSelector("#tabFrames > iframe:nth-child(1)"));
– Guy
Aug 13 at 7:12


driver.findElement(By.cssSelector("#tabFrames > iframe:nth-child(1)"));





I"m using xpath and it works.
– peterwkc
Aug 13 at 7:34

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS