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
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
Very Nice & Useful Post Mate !! Keep up the Good work....
ReplyDeleteI m sorry but following these steps running by junit I am getting error as "cannot find datapool".Can you plz guide me.
ReplyDeleteRanjana, you have to create properties file with name "datapool.properties" under your src folder
DeleteBest data driven testing example on web! Thanks a lot!!
ReplyDeleteIt was nice article it was very useful for me as well as useful forSelenium learners. thanks for providing this valuable information.
ReplyDelete