I have 10 Edit Boxes in my application. i Named them as Text1, Text2, Text3...Text10. Now i want to set values in these Text Boxes using Loop Statement. Can i Usefor i=0 to 10 browser("b1").page("p1").WebEdit("Text" & i).set "value" &inext**********Is it acceptable WebEdit("Text"&i) ? I am getting error here.Any suggestions?

Showing Answers 1 - 6 of 6 Answers

nagasenan

  • Mar 30th, 2006
 

Hi

It is 100% acceptable.

Here is the sample script which runs perfect.

For i=1 to 2

Browser("Welcome: Mercury Tours").Page("Book a Flight: Mercury").WebEdit("text" & i).Set "name" & i

Next

  Was this answer useful?  Yes

rupesh

  • Apr 4th, 2006
 

use descriptive programming in this situation in following way.

Assuming text is the name property by which QTP is identifying the webedit box:

box="name:=Text" & i

for i=0 to 10
browser("b1").page("p1").WebEdit(box).set "value" &i
next

  Was this answer useful?  Yes

Kaivalya

  • Dec 19th, 2006
 

Hi,

The idea is correct but implementation is wrong.

for i=0 to 10

*///browser("b1").page("p1").WebEdit("Text" & i).set "value" &i///*

Statment is not write.

You should use descriptive programming like this

browser("b1").page("p1").WebEdit(name:="Text" & i).set

Supposing name is property 


next

  Was this answer useful?  Yes

debleena23

  • Apr 17th, 2007
 

 

Hi

If you want to use descriptive programming then inyour case "Test1", "Text2".... are of "name" property. The other unique property can be "index"

For i=0 to 9

Browser("b1").Page("p1").WebEdit(name:="Text1","index:=" & i).Set Value

  Was this answer useful?  Yes

CRC

  • Apr 17th, 2007
 

Dim a, i
Window("Program Manager").WinListView(SysListView32).Activate"text htmt"
for i = 1 to 10 step 1
a = inputbox ("Enter the Text")
Browser("BrowserName").Page("PageName").WebEdit("name:=text" &i).Set a
Next

  Was this answer useful?  Yes

harinder p singh

  • Nov 7th, 2007
 

Browser("Welcome: Mercury Tours").Page("Book a Flight: Mercury").WebEdit("text" & i).Set "name" & iNextHere objects need to be present in the OR 

FOr the below one

For i=1 to 2Browser("Welcome: Mercury Tours").Page("Book a Flight: Mercury").WebEdit("text" & i).Set "name" & i

Next
 Here no objects needed to be present in the OR
 

 

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions