I want to select a nested iframe in an iframe with the selenium webdriver module in node-js.
For instance:
<iframe id="firstframe"> <div id="firstdiv"></div> <iframe id="secondframe"> <div id="seconddiv"></div> </iframe> </iframe>
for the node-js part:
driver.switchTo().defaultContent(); driver.switchTo().frame("firstframe"); // --> works driver.switchTo().frame("secondframe"); // --> NoSuchFrameError iframes = driver.findElements(webdriver.By.tagName('iframe')).then(function(elements){ console.log(elements.length); // --> if I put this code before the switch to first frame output: 1, if I put it after output: 0) });
I tried using the index number, but that also failed.
Edit:
Ok, I get it, but my answer was deleted by @casparOne for some reason. If someone still wonders what the problem is here:
My code above works, not locally. Chrome's security settings refuse to go deeper into the iframe in the local file. Therefore, it did not even show the source code for the iframe.
source share