Alternative to Excel and Database for Data-Driven Approach

1,273 views
Skip to first unread message

sirus tula

unread,
Sep 12, 2012, 2:48:34 PM9/12/12
to seleniu...@googlegroups.com

Hello Selenium Experts,

I have implemented Page Factory Object model with selenium webdriver for my new automation project. Currently i have all my test data hardcoded in separate class file that is called upon my multiple tests. So far it's been pretty awesome.

Now, I was thinking of using excel sheet for test data storage for data-driven framework and i've done before that as well. However, i have 100+ test data type variables which means i need to assign one column for every test data type which i'm not that comfortable to do. Also to add on that, i am not authorized to use database(DB) for test data storage.

So my final question, Is there any alternative to Excel for data-driven automation? I have used Database before for storing and extracting the data but
that option is not viable now.


What are your suggestions/advice on this particular issue?

Any help would be appreciated.

Thanks

Sirus

Ross Patterson

unread,
Sep 12, 2012, 3:01:11 PM9/12/12
to seleniu...@googlegroups.com

XML or JSON are much better models for storing values that would be represented sparsely as a spreadsheet.  Plus, they’re not spreadsheets, which means you don’t have to bend over backwards to read them in code.

 

Ross

sirus tula

unread,
Sep 12, 2012, 3:59:06 PM9/12/12
to seleniu...@googlegroups.com
Thank for your response, Ross.
 
I've thought about using XML but i have no clue on JSON.
 
Using XML, i think we can have multiple element tags and call those tags but how can we iterate the test with different values for the same test data type? For instance, i want to run the tests that has test data type as name and i want to iterate it with 10 different names.
 
How could we possibly do it using XML?
 
Would you mind explaining it to me?
 
Thank you again, Ross.
 
Thanks,
 
Sirus

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ross Patterson

unread,
Sep 12, 2012, 4:05:21 PM9/12/12
to seleniu...@googlegroups.com

Any decent programming language will allow you to iterate over a collection of elements, whether they’re XML or JSON, just like you could (painfully) iterate over a collection of rows in a spreadsheet.  As to generating the values, well, you’d have that problem with a spreadsheet too, so solve it the same way.

sirus tula

unread,
Sep 12, 2012, 5:39:45 PM9/12/12
to seleniu...@googlegroups.com
Thank you Ross,
 
I used For-each loop for every row in the excel csv file to parameterize into Excel sheet. I think i might have to do same. I will dig online into more resources of how to parameterize XML data.
 
Thanks again for your input.

Sirus

--

Manoj Hans

unread,
Sep 13, 2012, 12:51:46 AM9/13/12
to seleniu...@googlegroups.com

Anji Prassana

unread,
Sep 13, 2012, 1:25:59 AM9/13/12
to seleniu...@googlegroups.com
Hi,
  ha, it's all about how you organize your xml. First, We need to define a schema file[.dtd or .xsd] on our own which is compatible with our data model [ofcourse, creating a schema file is optional.But, better if we do so]. Then, Based on this schema file, we need to create an XML file.In your example,
 
 You may decalre one tag named as <usernames> followed by 'N' number of <username> tags.
 Like,
     <usernames>
      <username type="user">Tester</username>
      <username type="admin">Manager</username>
      <username type="admin">TestDirector</username>
      <username type="Power">Asst.Manager</username>
    </usernames>
Now, It's all about how you parse this xml and get the data defined in it and used in your testdata...
 
I mean, prior to testcase begin, you can parse this xml file and store all the usernames in a list and then you can iterate through all the elements in this list as you said through a for-loop in your testcase.
 
If you are using the Java with selenium, You can use either DOM,SAX or STAX parser API to Parse your XML Document. I would suggest you go with SAX or STAX parser instead of DOM. Because, all we do is just reading the XML in our program.So, for reading purpose, SAX or STAX are very good when compared to DOM[Which loads the entire XML elements into memory].
--
Thanks&Regards
Anjaneyulu P
"The way you see the things is the way to think and is the way you react upon!!"

Reply all
Reply to author
Forward
0 new messages