This article will show how we can refresh the current URL. There are many ways we can do this in selenium using java.
1.) Refresh
driver.navigate().refresh();
Using the navigate method and then refresh will refresh the page.
2.) getCurrentUrl
driver.get(driver.getCurrentUrl());
Using the driver get method and then passing the getCurrentUrl will again reload the page we are currently on, which is equal to refreshing the page.
3.) Navigate And Get the Current URL
driver.navigate().to(driver.getCurrentUrl());
This is done by navigating and using the 'to' method and passing the getCurrentUrl.
4.) F5
driver.findElement(locator).sendKeys(Keys.F5);
Using the send-keys and keys to mimic keyboard actions, we can pass F5, which refreshes the page.