I use Nightwatch to verify that the correct value has been assigned divin the iframe.
My html;
<div class="o-ads__inner" id="leaderboard-gpt">
<div id="google_ads_iframe">
<iframe id="some_id">
#document
<html>
<head></head>
<body>
<div id="ad-data" creative-id="53134803289">
</div>
</body>
</html>
</iframe>
</div>
<iframe></iframe>
</div>
This is my night time test;
module.exports = {
'Leaderboard Visibility' : function (client) {
client
.url(some_url)
.waitForElementVisible('body', 5000)
.waitForElementPresent('#leaderboard > iframe', 10000)
.pause(5000)
.frame(0)
.pause(5000)
.waitForElementPresent('div#ad-data', 5000)
.assert.attributeContains('div#ad-data', 'creative-id', '53134803289')
.end();
}
};
The error I get from Nightwatch is that Timed out while waiting for element <div#ad-data> to be present for 5000 milliseconds.I know that it is there, checking before an unsuccessful string.
I put 2 .pause(5000), since similar questions suggest that it might be a problem that the contents in the iframe are not loading fast enough. I don't think the case here is due to some debugging that I did, but I left them there for now.
I think I can’t access div#ad-datait because the iframe has its own property contentDocumentthat contains headboth body(and therefore subsequent divs).
div iframe contentDocument Nightwatch?