Welcome to the Exciting world of Selenium
If you are new to selenium, here is a step by step plan for getting started with Selenium. We have many examples (and will keep adding) which helps you to learn, practice and became an expert in automation using selenium and prepared to implement a framework for your project.
Lets Get Started with Selenium Webdriver
Selenium is a web Automation tool which can be used to automate web browsers across many browsers and operating systems.
Before jumping onto selenium in details, you should have a minimal knowledge of Java as going forward all the examples will be using java as programming language and near future we will add other languages for scripting and Basic knowledge on HTML will help to create effective scripts and construct reliable css/xpaths.
If you're not expert in java language or new to it, nothing to worry much, but your progress depends on how comfortable your are with the programming language that you choose.
In order to write our test scripts, you may need an IDE / editor. There are many open source editors available in the market. Here we will be mostly using Eclipse/IntelliJ.
2. Download IDE / editor (To Create and run your tests)
3. Download Selenium Webdriver.
Before starting to write your first test, know more details about selenium - Introduction to selenium And also Why Automation Testing is required? to know why we go automation (If you are new to automation).
Starting with Selenium, Let us first have a look at - Basic HTML concepts required for Selenium . You might be wondering why I should learn HTML?. The basic structure of an HTML document which includes Tags, Attributes and Elements.
There are many web browsers available in the market like Chrome, Firefox, Internet Explorer, Edge, Safari etc. To start with, first choose one browser from list of the browsers that you want to focus on executing your tests.
In the beginning, Selenium 3 version was not fully supported with Mozilla, As Mozilla was changing the internals of Firefox browser to make more stable and secure, and they are improving.
If you want to write your tests on Firefox browser using selenium 3, you'll need to have geckodriver, which is an executable similar to the chromedriver and edgedriver. But note that 'geckodriver' has to release stable version and they are still pending with few implementations like Actions class.
You can also use other browsers like Chrome and IE / Edge Browser, which ever you are comfortable with. Below are the syntax listed to run selenium;-
Selenium Webdriver 3.0
System.setProperty("webdriver.gecko.driver","path of geckodriver.exe"); WebDriver driver = new FirefoxDriver();
Selenium Webdriver 2.xx
WebDriver driver = new FirefoxDriver();
To execute your scripts on Chrome browser
System.setProperty("webdriver.chrome.driver", "path of chromedriver.exe"); WebDriver driver = new ChromeDriver();
Now here we go with selenium examples to start with Chrome, Mozilla, Internet Explorer and New Microsoft Edge Browser. If you are using eclipse as your IDE, then here is an example for you - Selenium webdriver using Eclipse
After opening a browser, the very first thing we would like to do is to navigate to a web page. Which we will do this by calling
driver.get(string URL) method and make sure you always give fully qualified URL. You can also use
driver.navigate.to(java.net.URL url) which is Overloaded version of
You can check here for Navigation Methods in Webdriver with Examples And also check for the difference between Webdriver get() and Webdriver navigate()
Now its time to check out for different webdriver methods that are available with selenium WebDriver Methods
To perform any action on a web page, you will often need to define a locator to query the browser DOM for elements based on the scenario. It will be useful to know how CSS and/or XPaths are defined as we will be using them very frequently when automation any web application.
There are total 8 locators available to find elements on web page and perform any action using them. You can find below listed topics/examples to better understand more about locators and how to use these locators to construct reliable paths.
Along with selenium scripts, we will also start using unit testing framework 'TestNG/JUnit' along with build automation tools like Maven/Ant. There are many other tools / libraries that will come across when working on a project which we will also cover like JExcel / Apache Poi to read and write excel sheets etc.
We have listed below topics/examples as Basic Selenium WebDriver Tutorials you should know and practice them using the demo website that we have built. It has almost all the functionalities that are used by most of the developers to build their web application.
Different examples to work with Alerts, Windows, Frames and Authentication Window
Upload and Download Examples:
Advanced Selenium WebDriver Tutorials
Selenium Framework Examples
If You are unable to find the solution here,
please feel free to send us your query to firstname.lastname@example.org