Unlike Selenium 2, Selenium 3 needs Mozilla GeckoDriver for executing the automation scripts on Firefox browser.
Lets follow the below steps for executing Selenium 3 automation scripts on Firefox browser using Mozilla GeckoDriver:
1. Create a new Java Project in Eclipse IDE as shown below:
2. Create a folder say 'libraries' inside the above created project as shown below:
3. Open http://www.seleniumhq.org/download/ and click on 'download' option of Java under 'Selenium Client & WebDriver Language Bindings' subheading as shown below:
Note: The Selenium version I am downloading in this example is Selenium 3 version i.e. 3.4.0. The version may change as the time passes.
4. A zip file containing the JAR files of Selenium 3 for Java will be downloaded as shown below:
5. Extract the ZIP file and observe that the below folder will get extracted:
6. Open the folder and copy the displayed JAR file as shown below:
7. Paste the above copied JAR file into the 'libraries' folder in Eclipse IDE as shown below:
8. Now again go to the folder path which is shown in step 6 and open the 'lib' folder shown below:
9. Copy all the JAR files displayed inside the above opened 'lib' folder as shown below:
10. Paste the above copied JAR files into the 'libraries' folder in Eclipse IDE as shown below:
11. Right click on the Project , select 'Properties' option and observe that the 'Properties' dialog of the Project will be displayed as shown below:
12. Select 'Java Build Path' > 'Libraries' tab > 'Add Jars' button as shown below:
13. Select all the JAR files displayed under the 'libraries' folder of the Project and click on 'OK' followed by 'Apply' button as shown below:
14. Observe that all the Selenium JAR files under the 'libraries' folder are not configured to be used inside the Project and displayed as shown below:
From the above steps, we have configured the Java Project with Selenium 3 Jar files. But Selenium 3 needs GeckoDriver to execute the automation scripts on Firefox browser. Download GeckoDriver by following the below steps.
15. Create a folder say 'drivers' under the Project as shown below:
16. Open http://www.seleniumhq.org/download/ and click on Mozilla GeckoDriver version under 'Third party Browser drivers' subheading as shown below:
17. In the displayed web page, click on '32 bit version of windows' to download as shown below:
18. Observe that the below ZIP file will be downloaded:
19. Extract the above downloaded ZIP file and copy the below geckodriver.exe file from the extracted folder as shown below:
20. Paste the copied geckodriver.exe into the 'drivers' folder in Eclipse IDE as shown below:
Now Selenium 3 is configured inside the Project and geckodriver.exe required to run the scripts on Firefox browser is also available. Lets write the Selenium code to launch the Firefox browser, open http://www.omayo.blogspot.com , click on the 'Selenium143' link on the web page and finally close the browser by following the below steps.
21. Create a Java Class file under 'src' folder as shown below:
22. Write the below two lines of code, 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:
Note: Without the first line in the marked region, Selenium 3 wont be able to run the scripts on Firefox browser.
23. Now, I will write the code to open http://www.omayo.blogspot.com , click on the 'Selenium143' link on the web page and finally close the browser as shown below:
24. Install the latest version of Firefox browser and execute the above code and observe that the Selenium 3 automations scripts will get executed on the Firefox Browser with the help of GeckoDriver by performing the below:
- Firefox Browser will be lauched
- http://www.omayo.blogspot.com will be opened in the browser
- Browser will get maximized
- Selenium143 link on the web page will be clicked and opened in the browser
- Finally Selenium 3 closes the Firefox browser
Conclusion:
Hence Selenium 3 requires GeckoDriver to execute the automation scripts on the latest version of Firefox browser. Error will be displayed in the Eclipse IDE console, if the GeckoDriver path is not set before launching the Firefox browser.
4 comments:
Hello Sir
Is the same process will work with Linux centos os?
Superb Arun.
Nice Explanation..
Thank you :)
Post a Comment