Table of Contents
Enroll in Selenium Training

Let's look at the codes to refresh the Browser in many different ways with Selenium WebDriver. Sometimes on certain browsers or on certain pages, normal refresh command deos not work, in those situations we can easily usethese commands to solve out purpose.

  1. Refresh command: The most commonly used and simple command for refreshing a webpage.
driver.get("https://www.toolsqa.com");

driver.navigate().refresh();
  1. SendKeys command: Second most commonly used command for refreshing a webpage. As it is using a send keys method, we must use this on any Text box on a webpage.
driver.get("https://www.toolsqa.com");

// Element "s" is a Seach Text box on my website

driver.findElement(By.name("s")).sendKeys(Keys.F5);
  1. Get command: This is a tricky one, as it is using another command as an argument to it. If you look carefully, it is just feeding get command with a page URL.
driver.get("https://www.toolsqa.com");

driver.get(driver.getCurrentUrl());

  1. To command: This command is again using the same above concept. navigate( ).to( ) is feeding with a page URL and an argument.
driver.get("https://www.toolsqa.com");

driver.navigate().to(driver.getCurrentUrl());
  1. SendKeys command: This is the same SendKeys command but instead of using Key, it is using ASCII code.
driver.get("https://www.toolsqa.com");

driver.findElement(By.name("s")).sendKeys("\uE035");
Find Broken Links in Selenium
Find Broken Links in Selenium
Previous Article
Junit Test with Selenium WebDriver
Junit Test with Selenium WebDriver
Next Article
Lakshay Sharma
I’M LAKSHAY SHARMA AND I’M FULL STACK TEST AUTOMATION ENGINEER. Have passed 12 years playing with automation in mammoth projects like O2 (UK), Sprint (US), TD Bank (CA), Canadian Tire (CA), NHS (UK) & ASOS(UK). Currently I am working with KNAB bank as SDET. I am passionate about designing Automation Frameworks that follow OOPS concepts and Design patterns. https://www.linkedin.com/in/lakshay-sharma-a4216312/
Reviewers
Virender Singh's Photo
Virender Singh

Similar Articles