I want to operate on an element on a website, which is inside an iFrame and further inside a document tag. How to do that?
Are you referring to a structure like this?
<iframe id="FRAMENAME">
#document
<html>
CODE....
</html>
Yes. How to work with these?
Have you tried using XPath?
Yes. I did. I tried to copy the XPath from the webpage and use it, but due to this tag, it is not pointing on the correct element
Ok got it. You need to switch to particular iFrame before accessing its elements. Simply add a switchTo like this:
driver.switchTo().frame("FRAMENAME");
Sure Tim. Please let me know if it works for you
You might want to insert a wait for your IFrame and element to load.
You can also use
new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.name("FRAMENAME")));
It will wait until the IFrame becomes available
Is their any other way to do this? Just curious
No Tim.
At the moment, Selenium does not have any other ways to work with iframe
wrappers.
Hence you need to switch to specific one, to work with them.
You can also refer Selenium Focus Element Issues And How To Solve Them? | LambdaTest to learn more
ok. thanks for the help