There are many ways that we can refresh a web page in Selenium Webdriver tests. Here are listed some of them:
1) Using refresh() method of WebDriver
2) Using F5 key
3) Using Actions class of WebDriver
1) Using refresh() method of WebDriver
driver.navigate().refresh();This is most commonly used method.
2) Using F5 key
driver.findElement(By.name("q")).sendKeys(Keys.F5);This is also commonly used method. We must use it in any text field of the web page as it uses Send keys method.
3) Using Actions class of WebDriver
Actions actions = new Actions(driver); actions.keyDown(Keys.CONTROL).sendKeys(Keys.F5).perform();4) Using jQuery
JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("history.go(0)");5) Using navigate( ).to( ) method of WebDriver
driver.navigate().to(driver.getCurrentUrl());6) Using ASCII code
driver.findElement(By.name("q")).sendKeys("\uE035");