What if we want to write a short script that accesses values from the data Table.
1) Make sure that QTP (with a new blank test) and a blank notepad is open.
2) In the Data Table below write a, b, c in the first column A.
3) Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to "Windows Applications" tab and choose first option "Record and run test on any open windows based application." and click on ok.
4) Just highlight the notepad and write 'a' on it.
5) Click on Stop so as to stop recording.
6) In the expert view your script will look like this:
Window("Notepad").WinEditor("Edit").SetCaretPos 0,0
Window("Notepad").WinEditor("Edit").Type "a"
7) We have to make it look like this:
rc = DataTable.Value("A", dtGlobalSheet)
msgbox rc
Window("Notepad").WinEditor("Edit").SetCaretPos 0,0
Window("Notepad").WinEditor("Edit").Type rc
8) Save the Test.
9) Run the Test again with a blank Notepad open. It will enter all the three values from Data Table into the Notepad.
0 comments:
Post a Comment