134. Using navigate( ).to( ) command to open the specified URL







We can also use navigate( ).to( ) Selenium WebDriver method to open the specified URL page.

navigate( ).to( ) functions similar to get( ) command. But get( ) command is easy to type when compared to navigate( ).to( ) command.

Example:

Suppose if we have to open www.Selenium143.blogspot.com using navigate( ).to( ) command, then we have to write the statement as shown below:

_driver.navigate( ).to("http://www.Selenium143.blogspot.com");


Test Description:

Open www.Selenium143.blogspot.com using navigate( ).to( ) command.


Lets Implement This:

Pre-requisites:

1. Create a new Java Project say 'WebDriver-Project53' in Eclipse IDE
2. Configure the Project to work with Selenium WebDriver
3. Create a package say 'package53' under the newly created project.
4. Create a Java Class file say 'Class53' 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 'openSelenium143BlogPage( )'  to open the specified URL using the navigate( ).to( ) WebDriver command as shown below:




3. Save and Run the 'Class53.java' file by selecting the 'JUnit Test' option and ensure that our Automation Test has opened the Specified URL page 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.


But there is a difference between get( ) and navigate( ) WebDriver commands:
  • Using navigate( ).back( ) command we can move backward in our browser
  • Using navigate( ).forward( ) command we can move forward in our browser
You cannot navigate backward or forward your browser using the get( ) command. This is only possible with navigate( ) command only. 

Lets implement navigate( ).back( ) and navigate( ).forward( ) command in the next posts.


Please comment below to feedback or ask questions.

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


 




Followers

Labels