Subscribe Us

How To Refresh Webpage in Selenium Webdriver

.
Question : How To Refresh The Web page in Selenium Webdriver using Java ?

 Answer :
To refresh or reload the current web page we use navigate().refresh() command.

navigate().refresh();

refresh command is a predefined method provided by selenium webdriver Refresh in selenium is a navigation method used to reload the current web page.

Syntax
The Basic syntax of refresh method is given below
navigate().refresh();

Example
Example of refresh method is given below 
driver.navigate().refresh();

Selenium Code to Refresh the web page in Selenium Webdriver using  java 

package firstpackage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class ClickMethod 
{
public static void main(String[] args)
{
System.setProperty("webdriver.chrome.driver", "C:\\Software\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.facebook.com/");
driver.navigate().refresh();
}
}

Other Method to refresh a page :

1)Get Method

Example
driver.get("https://www.facebook.com");
driver.get(driver.getCurrentURL());

2)Navigate Method

Example
driver.get("https://www.facebook.com");
driver.navigate.to(driver.getCurrentURL());

3)Sendkey() with F5

Example
driver.get("https://www.facebook.com");
driver. findElement(By.id("username")).sendKeys(Keys.F5); 

4)Sendkeys () with ASCII Code

Example
driver.get("https://www.facebook.com");
driver. findElement(By.id("username")).sendKeys(“\uE035”); 

In this tutorial we learn how to reload page in selenium webdriver .Hope this tutorial helpful for you 😊

Thanks & Regards 
Sandeep Yadav

Related Post :
  • How to Close browser window in selenium ?
  • How to delete cookies in selenium ?
  • How to enter the url in selenium ?
  • How to enter the value in text box ?
Important Tags : How to refresh page in selenium webdriver , how to refresh the webpage in selenium webdriver , how to reload the web page in selenium , how to refresh page in selenium

How To Refresh Webpage in Selenium Webdriver



Post a Comment

0 Comments