Google+

410. Using navigate( ).back( ) command to move backward in our browser






As discussed in our previous post, the only difference between get( ) and navigate( ) commands is we can go backward and forward on our browser using navigate( ) command only.

In this post lets implement navigate( ).back( ) command to navigate backward in our browser.

Syntax:   _driver.navigate( ).back( );

Test Description:
Automate all the below specified steps:

1. Open www.Selenium143.blogspot.com using get( ) or navigate( ).to( ) command
2. Click on 'What is Selenium?' link 
3. When you are in the 'What is Selenium?' link page, use _driver.navigate( ).back( ) command to go back to your previous page i.e. www.Selenium143.blogspot.com page
4. Retrieve the page title using getTitle( ) to verify that you are in the www.Selenium143.blogspot.com


Lets Implement This:

Pre-requisites:

1. Create a new Java Project say 'WebDriver-Project54' in Eclipse IDE
2. Configure the Project to work with Selenium WebDriver
3. Create a package say 'package54' under the newly created project.
4. Create a Java Class file say 'Class54' under the newly created package as shown below:




Actual Steps:

1. Write the following code into the newly created Java Class file as shown below and make sure that you resolve all the errors before going to next step:




2. Write the test method 'navigateBack( )'  to demonstrate how to use navigate( ).back( ) command as shown in the below screenshot:




3. Save and Run the 'Class54.java' file by selecting the 'JUnit Test' option and ensure that our Automation Test has navigated our browser backwards as shown in the below video:


Watch the below video:

Click here to watch the video.

Download this Project:


Click here to download this project and import into Eclipse IDE  on your machine.



Please comment below to feedback or ask questions.

Using navigate( ).forward( ) command to move forward in our browser will be explained in the next post.


 

No comments: