Refresh a webpage in selenium

Refresh a webpage in selenium

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

driver.findElement(By textboxLocator).sendKeys(Keys.F5);

5. Passing ascii value of F5 key i.e. “uE035” using sendKeys command

driver.findElement(By textboxLocator).sendKeys("uE035");

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.

Selenium Webdriver Tutorial

От QA genius