How to create your first selenium test case ?

Posted in Selenium By Raj On October 2, 2017


In my previous article, we have seen How to create new selenium project using Eclipse, here, to execute our first test case I am going to re-use the same project, the site which I am going to test out here is Keysandstrokes

The use case which I have taken here also very simple search functionality, enter the keyword in the search box of my blog and click on the search button, on the next page it should show list of search results

I am using WebDriver which is an automation tool for testing of web applications, here I am going to test on chrome browser so, the first thing which I am going to do is downloading the chrome driver by visiting this link Download Chrome Driver

You need to set your chrome driver path into the system variable something like below

We are going to test this on chrome browser so, we need to create instance first then load the page using below code

The above code snippet will just load the page in the Chrome browser it will not do anything apart from that, but here, we need to perform some actions on the page, to perform actions first we need to identify the elements on the page

The HTML for search textbox and button is something like below, in order to get properties of search textbox and button first we need to get instance


Here to get the instance of search box the locator I am using is name attribute, once we get the instance to populate the text of search textbox we need to use sendkeys method

Once the text is populated then find out the button and perform click event

Final code is something like below