Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser refresh by Ctrl+F5 in WebDriver using Java

I have refreshed the browser in WebDriver using java as below code:

driver.navigate().refresh();

How can I do that by pressing Ctrl+F5 in WebDriver using Java?

like image 906
Ripon Al Wasim Avatar asked Sep 06 '12 12:09

Ripon Al Wasim


People also ask

How do you refresh a page in Java?

The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.

Which command used to refresh the page using Webdriver?

Using driver.navigate() command Selenium Webdriver provides inherent support for refreshing a webpage using its driver. navigate() command. This is by far the most preferred and widely used way of refreshing a webpage.

Can we refresh page using Selenium?

Most commonly used method for page refresh in Selenium is the driver. navigate(). refresh() method. Get method and navigate methods include the recursive ways to refresh a page in Selenium.


1 Answers

I think you can use the WebDriver and Actions instance as below:

Actions actionObject = new Actions(driver);
actionObject.keyDown(Keys.CONTROL).sendKeys(Keys.F5).keyUp(Keys.CONTROL).perform‌​();
like image 86
Ami Avatar answered Oct 16 '22 14:10

Ami