Tuesday, 22 October 2013

Import and Export from External Resources into datatable

We can import or export from below resources in datatable

-> Text file
-> Excel File
-> Database

Steps for Data Driven Testing using Data table

1) Genrate Basic Test and run it once
2) Launch Data Table and enter / Imprt test data
3) Connect test Data to the test
4) Run the test

Syntext for connecting test data to test using datatable

DataTable(Column id/"Column name", Sheet id/ Sheet name)


if we want to use Text file as resource, we can follow two syntex in datatable

1) First line is consider as Column header
2) in between two cloumn tab space is delimiter
2) from next line, the datatable consider as data.



if we want to use Excel file as resource, we can follow two syntex in datatable

1) First Row is consider as Column header
2) from second row, the datatable consider as data.



If we want to import above two files. follow below options

From Datatable -> Right Click-> File -> Import From file-> select Notepad or Excel



> if we record the application, the below code values are static.


Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set "Arunrajvdm"
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure "Arunrajvdm"
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click



If we want to use dynamic values using datatable, we are following below below methods

1) use datatable and set the script as


Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set DataTable(1,1)      ' 1 for First col, 1 for First Sheet(Global)
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure DataTable(2,1) ' 2 for Second col, 1 for First Sheet(Global)
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click


2) Use keyword and set the Parameter using configuring the value for DataTable

Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set Parameter("UserName")
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure Parameter("Password")
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click


3) use Data Driven Method




Consider below static input scripts


Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set "Arunrajvdm"
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure "Arunrajvdm"
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click
 




Tools-> DataDriver -> Select Variable and click Parameterize -> Parameterrize All -> Select parameter-> Select Parameter Options for type as DataTable and set the Name and sheet global or Action1

see below screen shot, its shows as input variables are constent. So want to change dynamic using this method.




 Select variable name and set global Sheet for Datatable






After that its set script as below automatically

Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set DataTable("UserName", dtGlobalSheet)
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure DataTable("Password", dtGlobalSheet)
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click



No comments:

Post a Comment