How to get data to test login for 20 users?

128 views
Skip to first unread message

Tahir Shabbir

unread,
Oct 28, 2011, 3:25:45 AM10/28/11
to Selenium Users
Hi,

Would like to know the standard followed by you all. I am running
tests on c#.net with NUnit fw.
Say I want to test login for 10 users. How would I get the data for
those 10 user
- should I fetch data from an excel sheet
- Or should I fetch data from db

Is there another way to this. Honestly I don't know how its done
elsewhere.


Regards
Tahir

Piotr K

unread,
Oct 28, 2011, 5:28:10 AM10/28/11
to Selenium Users
Hi Tahir

I'm using C# with Nunit also, and I'm fetching my login from Excel
sheet. I have following code:

string ExcelDataPath = @"c:\selenium\Login.xls";
Microsoft.Office.Interop.Excel.Application ExcelData = new
excel.Application();
// create the workbook object by opening the excel file.
excel.Workbook DataworkBook = ExcelData.Workbooks.Open(ExcelDataPath,
0, true, 5, "", "", true, excel.XlPlatform.xlWindows, "\t", false,
false, 0, true, 1, 0);
// Get The Active Worksheet Using Sheet Name Or Active Sheet
excel.Worksheet DataworkSheet =
(worksheet)DataworkBook.Worksheets.get_Item("Sheet1");

excel.Range range;
range = DataworkSheet.UsedRange;
string login = (range.Cells[2, 1] as excel.Range).Value2;
string password = (range.Cells[2, 2] as excel.Range).Value2;

driver.Navigate().GoToUrl("Enter here your login page");

driver.FindElement(By.Id("UserName_field")).SendKeys(login);
driver.FindElement(By.Id("Password_field")).SendKeys(password);

And prepare Login.xls file(A column name - Login, B column name -
Password).
You can put into my code some loop for 10 users.

BR,
Piotr

Freddy Vega

unread,
Oct 28, 2011, 11:28:40 AM10/28/11
to seleniu...@googlegroups.com
I recommend a database. Storing your test data in a database has many benefits. Among them:
- Searchable
- Easy to maintain
- Abstraction layer for your test data
- Reusable data
...

I use MySQL in my implementations with Perl's DBI. You can use a similar one for C#.

Krishnan Mahadevan

unread,
Oct 29, 2011, 12:08:36 AM10/29/11
to seleniu...@googlegroups.com
Test data generation can be either as simple as "Random data" being generated on the fly, or it can be "Persisted Data".

ExcelSheets,
DataBase,
YAML files,
JSON files,
CSV files

are all sources of data being saved. 

It really depends on what you are comfortable with, for saving the data.

Using a DB means you would have to setup a DB for that, create tables etc., if all of this is going to be a hazzle you could choose all the other formats. Binary files such as ExcelSheets do have a problem when it comes to merge conflicts (this applies only when you are dealing with a version control as well)

So there is actually no ONE correct answer to this question IMO.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/jptxkAieAOAJ.

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 this group at http://groups.google.com/group/selenium-users?hl=en.

Freddy Vega

unread,
Oct 29, 2011, 6:46:51 AM10/29/11
to seleniu...@googlegroups.com
Sure no matter what method you choose there will be setup involved. That being said, I still think you should leverage a db which is probably already being used anyways. IMHO.

Freddy Vega

Pedro Nascimento

unread,
Oct 29, 2011, 9:21:22 AM10/29/11
to seleniu...@googlegroups.com
I'd say to store them in the database for the benefits Freddy listed. If for some reason you can't, at least have them in a csv instead of stylesheets, and use the appropriate csv parser for the language. They're easier to understand and requires less fuddling with Excel.

Manar Husrieh

unread,
Oct 31, 2011, 3:18:43 AM10/31/11
to seleniu...@googlegroups.com

Hi,
I would agree with pedro about the csv files since they are easy to handle and easily understood and easy to read from them and some test frameworks support them..
Regards,
Manar Husrieh

On Oct 30, 2011 6:53 PM, "Pedro Nascimento" <pnasc...@gmail.com> wrote:

Manoj K

unread,
Oct 31, 2011, 8:27:47 AM10/31/11
to seleniu...@googlegroups.com
Hi,
 In my point of view Using the excel format or the CSV format will do the necessary job in a easy manner. Agree with Krishnan and Pedro. As Freddy said you can use DB too, if at all you are ready to set the things up integrating with DB.

I was using initially CSV but later started using Excelsheet.

There are lots of resources that tell you How to read inputs from excel sheet. You can refer this link http://seleniumsoftwaretesting.blogspot.com/2011/07/selenium-tutorial-data-driven-testing.html (- by one of our selenium user- Tarun S )

Thanks,
Manoj
Reply all
Reply to author
Forward
0 new messages