How to do a forced page refresh using selenium webdriver?

sreejith edayillam picture sreejith edayillam · Dec 6, 2011 · Viewed 19.5k times · Source

In my automation, at one point I have to refresh the page to get the updated page content. But during the refresh the webpage is asking for a confirmation to resend the data (basically an alert is displayed on the page).

Even though I switched the focus to the alert and accepted it, the page contents are not getting refreshed. If I manually do the same, page contents are getting refreshed.

Is there any alternative way to refresh the page using Selenium Webdriver apart from navigate().refresh() command?

Or is there any way I can click on the Retry button on the alert without accepting the alert??

Answer

Amey picture Amey · Jan 4, 2012

In ruby try using this - @driver.switch_to.alert.accept

this will click on Resend

java code driver.switchTo().alert().accept();