Micro Focus QTP (UFT) Forums
problem with edit box - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: problem with edit box (/Thread-problem-with-edit-box)



problem with edit box - vijay44 - 01-28-2010

Hi,
I have a edit box.
when i enter 2 in the edit box and click add button.
its adding 2 edit boxes .
now i need to enter data in the 2 edit boxes
similarly if i enter 4, i need to enter data in the 4 edit boxes.
so it all depends on the number which i enter in the 1st edit box.
iam stuck up with the implementation.
As i need to write a code so that if even i enter 10 in the 1st edit and click add button, i should be able to enter the data in the 10 edit boxes which gets populated.
Any help will be really appreciated.
Regards;
Vijay


RE: problem with edit box - manabh - 01-29-2010

Hi,
Check "name" property of the text boxes getting created at runtime. You can use descriptive porgramming to handle this situation.


RE: problem with edit box - sreekanth chilam - 01-29-2010

Hi,

Follow the below steps & try to implement on your own:
Step1. Create a Description Object for Edit(ex: WebEdit/WinEdit).
Step2. After giving 'n' in Editbox & clicking Add button , Use ChildObjects method & retrieve the Editbox object collection & get the Editbox count.
Step3. Use For loop & Set the required input values into all the Editboxes one by one.

Refer 'Help' file for more info. on 'ChildObjects' method.Smile


RE: problem with edit box - vijay44 - 02-01-2010

Hi,
I am using the following code.
As there are so many edit boxes, i am filtering it.

Code:
Browser("micclass:=browser").page("micclass:=page").WebEdit("name:=sourceMoreRows").Set 1------>acts as switch
    var= Browser("micclass:=browser").page("micclass:=page").WebEdit("name:=sourceMoreRows").GetROProperty("value")
Browser("micclass:=browser").page("micclass:=page").WebButton("Name:=More Sources").Click

Set WbEdit = Description.Create()
WbEdit("micclass").Value = "WebEdit"
WbEdit("html id").Value = sourceName_0
Set AllWbEdit = Browser("micclass:=browser").Page("micclass:=Page").ChildObjects(WbEdit)
NumberOfEdits=AllWbButton.Count
msgbox(NumberOfEdits)
For( i = 0 ,i<=var,i++)
WBname = AllWbEdit(i).GetROProperty("html id")
msgbox(WBname)
If trim(WBname) = trim(sourceName_0) Then
    AllWbEdit(i).Set "Test"

End If
Next
But the problem is when it adds new edit boxes, the name of the edit box changes
1st edit box name:sourceName_0
2nd edit box name:sourceName_1
and so on...
if i trim by name, i am able to set the value in only 1 edit box.
i want to set different values in the different edit boxes which populate after clicking add button.
Any help would be really appreciated.
Regards;
vijay


RE: problem with edit box - rajvanan - 02-01-2010

Pls check the link on Descriptive Programming

Its too good and then you can modify as per your requirements.


RE: problem with edit box - vijay44 - 02-01-2010

Code:
Browser("micclass:=browser").page("micclass:=page").WebEdit("name:=sourceMoreRows").Set 1------>acts as switch
var= Browser("micclass:=browser").page("micclass:=page").WebEdit("name:=sourceMoreRows").GetROProperty("value")
Browser("micclass:=browser").page("micclass:=page").WebButton("Name:=More Sources").Click

Set WbEdit = Description.Create()
WbEdit("micclass").Value = "WebEdit"
WbEdit("html id").Value = sourceName_0
Set AllWbEdit = Browser("micclass:=browser").Page("micclass:=Page").ChildObjects(WbEdit)
NumberOfEdits=AllWbButton.Count
msgbox(NumberOfEdits)
For i=0 to var
WBname = AllWbEdit(i).GetROProperty("html id")
msgbox(WBname)
If trim(WBname) = trim(sourceName_0) Then
AllWbEdit(i).Set "Test"


when i run this particular code i am getting general run error at

Code:
WBname = AllWbEdit(i).GetROProperty("html id")

Any help will be really appreciated.
Regards;
vijay


RE: problem with edit box - sreekanth chilam - 02-01-2010

Hi Vijay,

Try with the below code.

Code:
Set WbEdit = Description.Create()
WbEdit("micclass").Value = "WebEdit"
WbEdit("html id").Value = "sourceName.*"
Set AllWbEdit = Browser("micclass:=browser").Page("micclass:=Page").ChildObjects(WbEdit)
NumberOfEdits=AllWbEdit.Count
For i=0 to (NumberOfEdits-1)
    if AllWbEdit(i).GetRoproperty("html id")<>"sourceName_0" then
        AllWbEdit(i).Set "Test"
   End if
Next



RE: problem with edit box - vijay44 - 02-01-2010

Hi,
Thanks a lot, the above code works fine.
If at all i want to set different set of data.
what i mean is can i set test in the edit box 1 and test 2 in edit box 2.i want to set different sets of data.i want to use varying test data from the spread sheet.
using this code i can set only test in the edit boxes.
any help will be really appreciated.
Regards;
vijay