Google+

Executing Selenium 2 Automation Scripts on Firefox Browser

In order to execute the Selenium 2 automation scripts on Firefox browser, we need FirefoxDriver.

FirefoxDriver is the default driver in Selenium 2:

FirefoxDriver is developed and supported by Selenium guys. And also it is the default driver of Selenium 2. i.e. We dont have to download a separate FirefoxDriver for executing the Selenium 2 Automation scripts, its in-build in the Selenium 2 Jar files. So only thing required is to download the Selenium 2 Jar files and configure our Java Project using these Jar files and hence no need to download FirefoxDriver as it is already available in the downloaded and configured Selenium Jar files.



Executing Selenium 2 Automation Scripts on Firefox Driver

In order to execute the Selenium 2 Automation scripts, we need to configure the Java project using the Selenium 2.53.1 version Jar files. Selenium 2.53.1 version is the last version available in Selenium 2. And the compatible Firefox browser for this version is 47.0.1. Hence we need to use Selenium 2.53.1 with Firefox 47.0.1 for successfully executing the Selenium 2 automation scripts on a Firefox browser.

Lets practically execute Selenium 2 Automation Scripts on Firefox Browser using the inbuilt FirefoxDriver:

1.Create a new Java Project in Eclipse IDE as shown below:



2. Create a 'libraries' folder in the project as shown below:



3. Go to http://www.seleniumhq.org/download/ and click on 'Previous Releases' option as shown below:



4. In the resultant page, click on '2.53' link option as shown below:



5. In the resultant page, click on 'Selenium-java-2.53.1.zip' link option as shown below:



6. Observe that a Zip file will be downloaded and extract the download Zip file as shown below:



7. Open the extracted folder and copy the two jar files as shown below:



8. Paste the copied Jar files into the 'libraries' folder in Java Project as shown below:



9. Open the 'lib' folder inside the extracted folder as shown below:



10. Copy all the Jar files inside the 'libs' folder as shown below:



11. Paste all the Jar files into the 'libraries' folder in Java Project as shown below:



12. Now configure the Jar files in the 'libraries' folder. Right click on the Java Project and select 'Build Path > Configure Build Path' option as shown below:



13. In the resultant 'Properties' dialog, select 'libraries' tab and 'Add Jars' button as shown below:



14. In the resultant dialog, select all the Jar files under the 'libraries' folder and click on 'OK' and 'Apply' buttons until all the dialogs gets closed as shown below:



15. Observe that all the Selenium Jar files got configured and displayed as shown below:



16. Create a new Class in the Java Project as shown below:



17. Create a driver object for FirefoxDriver class as shown below:



18. Hover the mouse over the above error message and select the below displayed items to resolve the errors:



19. Observe that the errors got resolved and write the remaining Selenium code to navigate to http://www.omayo.blogspot.com, click on 'Selenium143' link on the page and close the browser as shown below:



20. Before running the above script, check the Firefox browser version you have in your machine. Open Firefox browser, select 'Help' menu and 'About Firefox' option as shown below:



21. Observe that the Firefox Browser version will be displayed as shown below:



22. But, we need the older version of Firefox Browser i.e. 47.0.1, which is compatible with the Selenium 2.53.1 version. In order to get the older version of firefox and also to stop the firefox from auto upgrading to the latest version, we have to follow the below steps.

23. In Firefox browser, select 'Tools > Options' as shown below:



24. Select 'Advanced > Update tab > Never check for updates' option as shown below:



25. Close the Firefox browser and uninstall it.

26. Go to http://www.filehippo.com , search for 'Firefox' and select the 'Firefox' option from the displayed search results as shown below:



27. In the resultant page, click on 'View more' option under the 'Older Version' as shown below:



28. In the resultant page, navigate until you find the Firefox Browser version 47.0.1 and click on it as shown below :



29. In the resultant page, click on 'Download this version' button as shown below:



30. Exe file of Firefox 47.0.1 version will be downloaded, double click to install it and launch the Firefox browser after installation and select 'Help' > 'About Firefox' option to find out the installed Firefox browser version. Observe that Firefox Browser version 47.0.1 is displayed and auto upgrading is not happening as shown below:



31. Now, we have the Java Project configured with Selenium 2.53.1 Jar files and also the compatible Firefox browser version 47.0.1 is installed. Lets execute the Selenium 2 Automation code as shown below:



32. On executing the above code, Firefox browser will be launched, User will be navigated to http://www.omayo.blogspot.com application, 'Selenium143' link on the page will be clicked and hence the user will be navigated to http://www.selenium143.blogspot.com page and finally the browser will close.

Conclusion:

In order to execute the Selenium 2 automation scripts on Firefox browser, we need to use the last version of Selenium 2 i.e. Selenium 2.53.1 along with its compatible Firefox browser version 47.0.1. Using the Selenium's inbuilt FirefoxDriver , we have to run the automation scripts on the Firefox browser.

No comments: