Micro Focus QTP (UFT) Forums
Reading Values from csv file and excel file - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Reading Values from csv file and excel file (/Thread-Reading-Values-from-csv-file-and-excel-file)



Reading Values from csv file and excel file - rdwaram - 01-06-2010

I would like to apologize if this is something that was already asked. I was unable to find them in the forums, therefore i am posting here.

I have simple login procedure by entering emailaddress and password in our windows application. I can easily parametrize these values in the datatable and use these values.
However i would like QTP to gather these values from a csv file/ excel file.

1. So if i have a simple csv file such as:

emailaddress user!@testing.com
password 1234abcd

What is the best way to gather this data, and apply it to a given textbox in the application.


2. Same scenario as above, how would i gather this from a xls file.


Your help is very much appreciated.

Thanks,
rd


RE: Reading Values from csv file and excel file - rdwaram - 01-06-2010

Just want to clarify the post above.

It would be very helpful to know a way to gather a username and password from an xls sheet, import it into the data table in runtime and then read those values from the datable into a enter in the windows application.


RE: Reading Values from csv file and excel file - wheelercha - 01-07-2010

Hi-
For Excel:
To load the table at runtime do this:
Datatable.AddSheet "NameYouGiveToARuntimeTable" ***Adds the Runtimetable with the given name
Datatable.ImportSheet "c:\YOURUSERNAMESANDPASSWORDS.xls", 1,"NameYouGiveToARuntimeTable" ****Imports the values of your spreadsheet into QTP at runtime. Be sure that you have a column Name for each Column (Email Address, Password)


To enter the value into the application you'll need either a loop or a conditional statement. QTP will attempt to use every row. So if the login is successful it moves forward, completes the test then reruns it with the second username and password.

A way to enter the data from the runtime datatable is this in a browser. For a windows application I am sure it's very similar:

Code:
Browser("NAME").Page("SomePage").WebEdit("TextBoxName").Set DataTable("Username", "NameYouGiveToARuntimeTable")
Browser("NAME").Page("SomePage").WebEdit("TextBoxName").Set DataTable("Password", "NameYouGiveToARuntimeTable")