Saturday, November 18, 2017

Five different ways to refresh the browser using Selenium WebDriver.

Below are the 5 different ways to refresh the browser using Selenium WebDriver.

Method 1: Using navigate.refresh()
Most of us know this approach, driver.navigate.refresh() will refreshes the current page.

Method 2: Using navigate.to()
In this approach using "driver.getCurrentUrl()" we will get the current url of the page and send to the navigate.to() method to refresh the page.

Method 3: Using get()
In this approach using "driver.getCurrentUrl()" we will get the current url of the page and send to the get() method to refresh the page.
Method 4: Using SendKeys()
In this approach we need to identify a text field on the page and send the key F5. When F5 is sent the page gets refreshed.

Method 5: Using SendKeys() and Unicodes
Send the unicode of the F5 key to text field on the page, that will refresh the page.
Special keys like F5, Space, Enter and ARROW_LEFT will be having the uni-codes, please refer here.
Different ways of refreshing the browser are mentioned below, please refer.

No comments:

Post a Comment

Selenium4: Working with two parallel windows in Selenium Automation

A new method newWindow() is introduced in Selenium 4 (Alpha). Using this method we can open a new tab or new window from the current window...