'Selenium Javascript - Access webelements within iframe programatically
I am trying to access web elements within iFrame programatically. Using below method to check the same
- Compare the URL of elements with the base URI
- If its same then web element is in main DOM otherwise its in iFrame
- Use switchTo.frame() to switch to iFrame and perform actions
In above method, the following methods used to get URI of element
document.getElementsByTagName("a")[0].baseURI;
or
document.getElementsByClassName("w3-btn w3-border")[0].baseURI
Queries:
Is there any function or method to get baseURI using xpath? I don't want to use Tagname or classname.
Also, how to achieve same when multiple iFrames or iFrame inside another iFrame.
Kindly suggest if any other method
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
