There was an error in this gadget

Technical Project Lead @ Huawei Technologies

My photo
Bangalore/Hyderabad, Karnataka/Andhra Pradesh, India
Have an overall 10 + yrs of experience Currently working as an Senior Architect.Expertise in design,implementation of Automation frameworks for Opensource automation tools like Selenium,Jmeter, Webdriver,Appium, Robotium Expertise in integrating Test & ALM Management tools like Rally,Qmetry,JIRA-Zephyr with Automation frameworks Expertise in design and developmenet Mobile Automation frameworks for tools like Appium, Robotium Remote Control,Cucumber BDD

Followers

Tuesday, October 12, 2010

How to do Data Driven Testing

Simplest way to drive the gui components using different sets of data is from a properties file. However we can use excel sheets as our data source. For small sets of data we can use the properties file

Here is the step by step Procedure which gives an idea on how to drive the Google search text box with different sets of data from a properties file

1.Create a Java Project in Eclipse.
2.Right click on the Source folder , go to File >> New >> File
3. Provide file name of your choice with an extension .properties . Ex give the file name as datapool.properties and click on Finish button
4. After clicking on Finish you should be able to see the file in the Project Explorer of eclipse as shown below
5.Open the datapool.properties, enter the key. Just copy paste the below line in the properties file & save the file .Refer below snapshot
Search_Criteria=SeleniumRC,SeleniumIDE,SeleniumGRID

6. Now that we have different sets of data in a resource called datapool.properties.
7.Next step is to read the properties file
8.Now create a Resource bundle object that reads the properties file
9.Now using the bundle object, Read the line of the properties file using the key Search_Criteria" 
10. bundle.getString("Search_Criteria") will return you the string of values for the specified key. 9.Now the String criteria will have value "SeleniumRC,SeleniumIDE,SeleniumGRID".
11.We will use the Java Utility called String Tokenizer to beak the above String into individual tokens identified by comma.
12.After Splitting for each token we will fill in the Google Search Text Box.
13.Copy the code from the below Image in your eclipse and run it

Below is the snapshot of the code

5 comments:

  1. Very Nice & Useful Post Mate !! Keep up the Good work....

    ReplyDelete
  2. I m sorry but following these steps running by junit I am getting error as "cannot find datapool".Can you plz guide me.

    ReplyDelete
    Replies
    1. Ranjana, you have to create properties file with name "datapool.properties" under your src folder

      Delete
  3. Best data driven testing example on web! Thanks a lot!!

    ReplyDelete
  4. It was nice article it was very useful for me as well as useful forSelenium learners. thanks for providing this valuable information.

    ReplyDelete