Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QTP and Excel
#11
Solved: 11 Years, 4 Months ago
Hi , I did as mentioned by Brian but now the code still executes twice so I actually have four runs when the datatable contains only two rows of data . Attached is the code ,

I just want the script to run once for each row of the datatable but for some reason it runs the script twice for each row ending up with four results .
----------------------------
Code:
Dim Row
DataTable.Import("E:\ITS\login.xls")
Row=1
'This loop iterates for each instance of the login name
Do while (Row < (Datatable.GetRowCount+1))
DataTable.SetCurrentRow(Row)

SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe","","C:\Documents and Settings\SSharma","open"
Browser("Home").Page("Home").Sync
Browser("Home").Navigate "https://www.ITS Inc.org/#"
Browser("Home").Dialog("Security Information").WinButton("Yes").Click
Browser("Home").Page("ITS Inc,.").WebEdit("txtusername").Set DataTable("username", dtGlobalSheet)
Browser("Home").Page("ITS Inc.").WebEdit("txtpassword").SetSecure "8e9d06e4654024dbf48"
Browser("Home").Page("ITS Inc").Image("header$loginButton").FireEvent "onmouseover"
Browser("Home").Page("ITS Inc").Image("header$loginButton").Click 11,11
Browser("Home").Page("ITS Inc").Link("LOGOUT").Click
Browser("Home").Page("ITS Inc").Sync
Browser("Home").Close

Row=Row+1
Loop

---------------------------------

Thanks ,

Sonia
Reply
#12
Solved: 11 Years, 4 Months ago
hi,
i am new in QTP .please tell how to study QTP easily and script
this is my mail id m.veerasekaran@gmail.com
Reply
#13
Solved: 11 Years, 4 Months ago
Hye Sonia,
The solution for ur question is quite simple.please use the below code with some modifications.

Code:
Datatable.ImportSheet "path.xls","Action name","sheet name"
'action name and sheet name must be same
num=datatable.GetSheet ("action name").Getrowcount
msgbox (num)
For i=1 to num
DataTable.GetSheet("action name").SetCurrentrow i
Browser("sdfs:=sdf").page("sdf:=dse").WebEdit("sdfee:=sd").Set datatable("user_ID",dtLocalSheet)
'use_id is a column in exl sheet
Browser("sdfs:=sdf").page("sdf:=dse").WebEdit("sdfee:=sd").click
Browser("sdfs:=sdf").page("sdf:=dse").WebEdit("sdfee:=sd").Set datatable("password",dtLocalSheet)

Browser("sdfs:=sdf").page("sdf:=dse").WebEdit("sdfee:=sd").click

Next


Pls let me know ur results

Regards
Raj
Reply
#14
Solved: 11 Years, 4 Months ago
Yes ,

Thank you for the information. Now the script works fine . I did not change the run on all rows setting earlier .

Thank you for your help,
Sonia
Reply
#15
Solved: 11 Years, 4 Months ago
Hi I tried the same thing for mercury tours windows application. here it takes all thedata from excel sheet. but my problem is for i=1 the script is runnig for 3 times (coz there are 3 rows in excel sheet)for i=2 its running 3 times.how to aviod this.thanks in advance.[/u]


Code:
Datatable.Import ( "C:\Documents and Settings\sailaja\My Documents\usename.xls")
num=datatable.GetRowCount
For i=1 to num
systemutil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
datatable.SetCurrentRow i

Dialog("Login").WinEdit("Agent Name:").Set DataTable("Agentname", dtGlobalSheet)
Dialog("Login").WinEdit("Password:").Set DataTable("password", dtGlobalSheet)
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").ActiveX("MaskEdBox").Type "020209"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "Sailaja"
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"

Window("Flight Reservation").Close

next
'o=createobject("scripting.filesystemobject")
'Set outputfile=fso.createtextfile("C:\Documents and Settings\sailaja\My Documents\output.xls",true)

  '  outputfile.writeline("step passed")
Reply
#16
Solved: 11 Years, 4 Months ago
HI sonia ,

Just check with the following method :

1. In file-->settings-->Run-->choose "Run only one iteration"

2.in the expert view, give the following code:

Code:
Dim Row
DataTable.Import("E:\OFT\login.xls")

rcount=datatable.getrowcount
For i=1 to rcount
DataTable.SetCurrentRow(i)
SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe","","C:\Documents and Settings\SSharma","open"
Browser("Home").Page("Home").Sync
Browser("Home").Navigate "https://www.ITS Inc.org/#"
Browser("Home").Dialog("Security Information").WinButton("Yes").Click
Browser("Home").Page("ITS Inc,.").WebEdit("txtusername").Set DataTable("username", dtGlobalSheet)
Browser("Home").Page("ITS Inc.").WebEdit("txtpassword").SetSecure "8e9d06e4654024dbf48"
Browser("Home").Page("ITS Inc").Image("header$loginButton").FireEvent "onmouseover"
Browser("Home").Page("ITS Inc").Image("header$loginButton").Click 11,11
Browser("Home").Page("ITS Inc").Link("LOGOUT").Click
Browser("Home").Page("ITS Inc").Sync
Browser("Home").Close
Next

Sonia....I hope ur problem will be solved...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  excel macro to open QTP from excel karthik1979_us 1 11,117 11-07-2009, 02:57 AM
Last Post: geethwind

Forum Jump:


Users browsing this thread: 1 Guest(s)