admin管理员组文章数量:1201788
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 refresh my page, is there any way to hard refresh the page using Selenium.
The code in any of Java/Python would be welcomed.
Note: I don't want to use Robot class to perform it, so please provide any other way to do it.
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 refresh my page, is there any way to hard refresh the page using Selenium.
The code in any of Java/Python would be welcomed.
Note: I don't want to use Robot class to perform it, so please provide any other way to do it.
Share Improve this question edited Feb 7, 2019 at 12:08 Sameer Arora asked Feb 7, 2019 at 10:54 Sameer AroraSameer Arora 4,5073 gold badges12 silver badges20 bronze badges 01 Answer
Reset to default 24A 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!
本文标签: javascriptHow to hard refresh using SeleniumStack Overflow
版权声明:本文标题:javascript - How to hard refresh using Selenium - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738639188a2104214.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论