How to refresh webpage using Action class in selenium WebDriver?

Refresh webpage using Actions Class in Selenium WebDriver –
There are various ways to refresh webpage in selenium webdriver. One of them using Actions class.
Refresh WebPage using Actions class in Selenium WebDriver
Application can be refreshed in multiple ways. We can use

driver.navigate().refresh();
Method, or can send key F5.
Here, Web Page refresh can be achieved by using Actions class of the selenium WebDriver.
Below program explain this –
package learnAboutActionsClass;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class RefreshUsingActionsClass {

 public static void main(String[] args) throws InterruptedException {
  // TODO Auto-generated method stub
  
  WebDriver driver = new FirefoxDriver();
  
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  driver.manage().window().maximize();
  
  driver.navigate().to("https://learnaboutsoftwaretesting.blogspot.in");
  
  //sleep the website for 4 seconds so that we can notice the refresh of web page
  Thread.sleep(4000);
  
  Actions act = new Actions(driver);
  
  //using below command we can refresh the webpage
  act.keyDown(Keys.CONTROL).sendKeys(Keys.F5).build().perform();
 }

}  

Leave Comment

Your email address will not be published. Required fields are marked *

Looking for learning Framework Development from Scratch? Lookout for Detailed Framework Development videos on YouTube here -

https://www.youtube.com/automationtalks

Get the Framework code at Github Repo: https://github.com/prakashnarkhede?tab=repositories