How to refresh the page using Selenium Java

asked 1 year ago

There are various ways we can refresh the screen, Selenium Webdriver provides a native method to refresh the screen

driver.navigate().refresh();

 

Other than this native method we can also refresh the screen 

Using Action class:

Actions actionObject = new Actions(driver);
actionObject.keyDown(Keys.CONTROL).sendKeys(Keys.F5).keyUp(Keys.CONTROL).perform();

 

Using SendKeys 

driver.findElement(By.xpath("//body")).sendKeys(Keys.F5); 

 

By Navigating to the current URL again 

driver.navigate().to(driver.getCurrentUrl());

 

 

Categories