Google+

Selenium 3 & get( ) command - Using get( ) command to open the specified URL page

Selenium WebDriver of Selenium 3 has the same commands which are available with the Selenium 2.

Though the commands are same, I would like to demonstrate the same commands with Selenium 3.

In this post, I will be demonstrating on how to use get( ) command for opening the specified URL page with Selenium 3.



Prerequisite:

Before using the get() command with Selenium 3, we have to first create an Java Project in Eclipse IDE and configure that with Selenium 3 & GeckoDriver for Firefox Browser. Please go through the below link for the same:

  • Click here to configure the Java Project with Selenium 3 and GeckoDriver for Firefox Browser
  • Also, install the Latest version of Firefox Browser in your machine. (At the time of writing this post, I have installed the Firefox Quantum Browser having version 58.0.2)

Once the above configuration is done, go through the below steps for implementing get( ) command for opening the specified URL page with Selenium 3:

1. Create a Java class file under 'src' folder as shown below:




2. Write the two lines of code shown in the screen-shot, in which the first line will set the path to geckodriver.exe file, which is required by Selenium 3 to run the scripts on Firefox browser and the second line will open the Firefox browser:



3. Now, lets write the code which uses get( ) command of Selenium WebDriver for opening the specified URL in the browser as shown below:



4. Click on the 'Save All' button to save the so far written code as shown below:



5. Right click on the newly created Java Class and select to Run As >> Java Application as shown below:



6. Observe that the latest version of Firefox Browser version will be launched and the URL specified in the get( ) command will be opened in the launched Browser as shown below:




Conclusion:

The same get( ) command in Selenium WebDriver of Version 2 is used for opening the specified URL in Selenium 3 version too. 

No comments: