5

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?

1 Answer 1

8

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‌​();
Sign up to request clarification or add additional context in comments.

3 Comments

I ran the above code. Unfortunately, the following exception was occurred: java.lang.IllegalArgumentException: Key Down / Up events only make sense for modifier keys.
Ctrl is a modifier key but F5 is not. You probably want to use actionObject.keyDown(Keys.CONTROL).sendKeys(Keys.F5).keyUp(Keys.CONTROL).perform();
Thanks. The above code is helpful for me. "The method perform‌() is undefined for the type Actions" : this error was shown on above code. Small modified code is as below: actionObject.keyDown(Keys.CONTROL).sendKeys(Keys.F5).perform();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.