In this blog, you will be given an opportunity to get used to Selenium automation testing as well as the basic instructions on how to write a script in Selenium WebDriver with sample Java code to get you started.


The tutorial provides automation testers the basic knowledge of how to write the script in Selenium Webdriver and practical examples. The article contains enough ingredients to let you start with Selenium WebDriver from where you can independently take yourself to higher levels of expertise.


Before starting with this tutorial, you need to have a basic knowledge of Java or any other object-oriented coding language. Moreover, you should be proficient in the basic principles of testing concepts, especially the concept of Selenium Automation Testing.

Getting Started With Selenium WebDriver Scripting

Assume that you want to write the script in Selenium Webdriver that could:

  • Fetch Fox News’ homepage
  • Verify its title
  • Print out the result of the comparison
  • Close it before ending the entire program

WebDriver Code

Below is the Selenium WebDriver example for the logic presented by the scenario mentioned above.

Note: Gecko driver generated by Mozilla should be taken into account when using WebDriver. Selenium 3.0, Firefox, and Gecko have compatibility issues and setting them appropriately could become a difficult task. If the code cannot be activated, the lower version of Firefox should be downloaded. Otherwise, you can run your Selenium script on Chrome. You only need to change three lines of the code to let your script work with Firefox or Chrome.

Leave a comment

Your email address will not be published. Required fields are marked *