Friday, October 31, 2014


Sometimes we need to refresh the current web page to reload or to get the new dynamic value.

 driver.navigate().refresh() - This command is used to refresh the current page.

Refresh Current Web Page Example






import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class SeleniumRefresh {

 public static void main(String[] args) {

  WebDriver driver = new FirefoxDriver();
  driver.navigate().to("http:// www.google. com");
  WebElement element = driver.findElement(By.name("q"));
  element.sendKeys("Selenium");
  driver.navigate().refresh();

 }

}