More robust waiting for iframe to be ready

This commit is contained in:
Jaifroid 2025-06-15 13:01:57 +01:00
parent e846b3e07a
commit 185cb9c669

View File

@ -285,7 +285,17 @@ function runTests (driver, modes, keepDriver) {
} catch (e) {
// Handle cases where the frame or element is not accessible
await driver.switchTo().defaultContent();
elementText = await driver.executeScript('var iframeDoc = document.getElementById("articleContent").contentDocument; return iframeDoc.getElementById("mwYw").textContent;');
// Wait for the iframe to be available before switching to it
await driver.wait(until.elementLocated(By.id('articleContent')), 5000);
await driver.switchTo().frame('articleContent');
// Wait for the target element to be available within the iframe
const element = await driver.wait(until.elementLocated(By.id('mwYw')), 5000);
elementText = await element.getText();
// Switch back to default content
await driver.switchTo().defaultContent();
}
// Assert that the article content matches the expected value