How To Hard Refresh Using Selenium
We have various ways in Selenium like driver.navigate().refresh(); and driver.execute_script('location.reload()') to do refresh, but these perform normal refresh. I want to hard re
Solution 1:
A Regular refresh may reload the page from its cache.
A Hard refresh reloads from the server, not from cache.
If you wish to delete the Cache too use Cache.delete()
:
see MDN Web Docs on Cache.delete().
The answer:
You can use location.reload(true);
with execute_script
:
driver.execute_script("location.reload(true);")
Reloads the resource from the current URL. Its optional unique parameter is a Boolean, which, when it is true, causes the page to always be reloaded from the server. If it is false or not specified, the browser may reload the page from its cache.
For more info see MDN Web Docs on Location.
Hope this helps!
Post a Comment for "How To Hard Refresh Using Selenium"