Micro Focus QTP (UFT) Forums
Unable to click on the WebButton with specified Index - 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: Unable to click on the WebButton with specified Index (/Thread-Unable-to-click-on-the-WebButton-with-specified-Index)



Unable to click on the WebButton with specified Index - srach84 - 03-30-2015

Hi,

There are multiple buttons on a web page with the same name - "Edit". I have tried to use Descriptive Programming/Index property to click on the WebButton with a certain Index. However, the script clicks on a button with the Index=0.
Please find the screenshots with explanation and advise me on the code to provided in the script.

Thanks,
Shilpa R.


RE: Unable to click on the WebButton with specified Index - supputuri - 03-30-2015

Are you using descriptive programming or object repository? I hope the edit button might be added under first container that the reason why it's hitting the first button always. Check the hierarchy in your script or object repo.
if you need any further help please post the pseudo-code and object spy screenshots of the 2 edit bottons.


RE: Unable to click on the WebButton with specified Index - srach84 - 03-31-2015

Hi,

I have used descriptive programming to click on the Edit button as below, however, it still selects the first Edit button instead of the Index
Code:
Descriptive Programming Code –
Set oLink=Description.Create()
oLink("micclass").value="WebButton"
oLink("html tag").value="INPUT"
oLink("type").value="submit"
oLink("class").value=" linkbtn_"
oLink("value").value="Edit"
                            
Set LinkCount=Browser("AUS Online Banking - Batch").Page("AUS Online Banking - Batch").ChildObjects(oLink)
        
For n=0 to LinkCount.Count-1
                                                LinkTitle=LinkCount(n).GetROProperty("value")
                                                    msgbox LinkTitle
                                                    If LinkTitle="Edit" Then
                                                        LinkCount(n).WebButton("name:=Edit.*","Index:=j+1").Click
                                                       Exit For
                                                    End If
Next

Code to select the Edit button based on the Index provided in the Object repository

Set oDesc=Description.Create()
oDesc("micclass").value="WebButton"
oDesc("html tag").value="INPUT"
oDesc("class").value="linkbtn_ flblinkbtn_"

Set ButtonCount=Browser("AUS Online Banking").Page("AUS Online Banking - Batch").ChildObjects(oDesc)
'msgbox ButtonCount.Count
For j=0 to ButtonCount.Count-1
'msgbox j
ButtonTitle=ButtonCount(j).GetROProperty("value")
'msgbox ButtonTitle
If ButtonTitle=DataTable("BatchDebitTempDesc","Global") Then
ButtonCount(j).Click
'Browser("AUS Online Banking").Page("AUS Online Banking - Batch").WebButton("name:=Edit","Index:=&j+1").Highlight
Browser("AUS Online Banking").Page("AUS Online Banking - Batch").WebButton("Edit_"&j+1).Click
Exit For
End If
Next

On the other side, I have added the same Edit object with different Indexes in the Object Repository named as Edit_1, Edit_2, etc. and provided the code as below. The Edit button is clicked based on the position of the Index. However, this might not work if there are large number of Webbuttons with the same name as it is a tedious process to add the same object with different name in the Object Repository.

Please find the attachment on the code and snaphots of the Object repository and the Object properties from Object Spy.

Thanks,
Shilpa