top of page
heena51

Selenium WebDriver - Navigation Commands

WebDriver provides some basic Browser Navigation Commands that allows the browser to move backwards or forwards in the browser's history. To access the navigation's method, just type driver.navigate(). The IntelliSense feature of the eclipse will automatically display all the public methods of Navigate Interface shown in the below image.


Note: The Methods having "Navigation" (highlighted in yellow color) as keyword are declared as Navigation commands.


1. Navigate To Command

to(String arg0) : void

This method loads new web page in the current browser window. It accepts String as parameter and returns void.


Command - driver. navigate().to(url);


Note: The get command driver. get(url); which is browser command does the same function as the navigate to command.

2. Froward Command

forward() : void

This method does the same operation as clicking on the Forward button in the existing browser window. It neither accepts anything nor returns anything.


Command - driver. navigate().forward();


The respective command that takes you forward by one page on the browsers history


3. Back Command

back() : void

This method does the same operation as clicking on the Back button in the existing browser window. It neither accepts anything nor returns anything.


Command - driver. navigate().back();


It takes you back by one page on the browser history.


4. Refresh Command

refresh() : void

This method refresh the current page. It neither accepts anything nor returns anything.


Command - driver. navigate().refresh();


It does same function as F5 in the browser.


Exercises

1. Launch new browser

2. Open newtours.demoaut.com website

3. Print page title of Home page in console window

4. Open facebook.com using navigate to command

5. Print page title of Facebook page in console window

6. Come back to home page (use 'back' command)

7. Again go back to Facebook page(use 'forward' command)

8.Refresh the browser (use 'refresh' command)

9. Close the browser

Solution:


















2 views0 comments

Recent Posts

See All

Battle of the Backends: Java vs Node.js

Comparing Java and Node.js involves contrasting two distinct platforms commonly used in backend development. Here’s a breakdown of their...

Comments


bottom of page