There are multiple ways of refreshing a page in Selenium Webdriver. In this post, we will present all these ways and also specify which one is the best.
1. Using driver.navigate() command
Selenium Webdriver provides inherent support for refreshing a webpage using its driver.navigate() command. This is by far the most preferred and widely used way of refreshing a webpage.
2. Opening current URL using driver.getCurrentUrl() with driver.get() command
3. Opening current URL using driver.getCurrentUrl() with driver.navigate() command
4. Pressing F5 key on any textbox using sendKeys command
5. Passing ascii value of F5 key i.e. “\uE035” using sendKeys command
That’s all we have in this post, comment below if you have any queries. Also please share this post with your friends and don’t forget to check our complete selenium tutorial here.
Kuldeep is the founder and lead author of ArtOfTesting. He is skilled in test automation, performance testing, big data, and CI-CD. He brings his decade of experience to his current role where he is dedicated to educating the QA professionals. You can connect with him on LinkedIn.
2 thoughts on “Refresh a webpage in selenium”
I do not want to refresh the page. How or can I refresh just the DOM content? In Telerik you can refresh the DOM content without refreshing the page. I was wondering if Selenium had something similar? Thanks for any help you can give.
I get Compiler Error CS0201:
Only assignment, call, increment, decrement, and new object expressions can be used as a statement