Reputation: 33
Im trying to traverse through the local .html file where there is an iFrame and the #document under this, is not getting loaded when it is running via automation using selenium.
Running via selenium driver:
<iframe id="xxxxx" name="yyyy">
.. Nothing is displaying ..
Opening the html file manually or by refreshing via browser refresh button:
<iframe id="xxxxx" name="yyyy">
#document
<html>...</html>
Note: In the same session using debug mode, if we page load it manually using browser refresh, the #document gets loaded but if we press "Step Over" in debug mode and move to next step, then again #document goes missing.
Tried all the below page load but the result is same: #document under iFrame goes missing as soon as any step is carried out via driver object.
PFB the page refresh which were tried,
public void driver_refresh() {
getDriver().navigate().refresh();
wait_for_element(3);
}
public void action_refresh() {
Actions act = new Actions(getDriver());
Action a1= act.keyDown(Keys.F5).keyUp(Keys.F5).build();
a1.perform();
}
public void js_refresh() {
((JavascriptExecutor) getDriver()).executeScript("history.go(0)");
wait_for_element(3);
}
public void robot_refresh() throws Exception {
Robot r = new Robot();
r.keyPress(KeyEvent.VK_CONTROL);
r.keyPress(KeyEvent.VK_R);
r.keyRelease(KeyEvent.VK_R);
r.keyRelease(KeyEvent.VK_CONTROL);
}
public void robot_refresh_f5() throws Exception {
Robot r = new Robot();
r.keyPress(KeyEvent.VK_F5);
r.keyRelease(KeyEvent.VK_F5);
wait_for_element(5);
}
public void waitForLoad() {
new WebDriverWait(getDriver(), 30).until((ExpectedCondition<Boolean>) wd ->
((JavascriptExecutor) wd).executeScript("return
document.readyState").equals("complete"));
}
Upvotes: 1
Views: 310
Reputation: 33
All - Checked other steps before a point where i faced issue to see whether the #document was loaded in run time but it was not and it was still able to do those actions.
Hence, checked my full code and I was doing a page refresh in between, so the page objects were lost in runtime because I have page factory of elements.
Now removed the page refresh in between and continued in the same session - Though #document is not loaded, the required actions from selenium webdriver is performed.
Upvotes: 1