QTP: HTML Tag is recognized, but click function does not have response

1.6k views Asked by At

In QTP11, I have a function as below to handle a drop-down list button. The HTML structure is as follows:

enter image description here Sub FindDropdown(text) ' get page and text as parameter counter = 0

Set oDesc = Description.Create()
oDesc("html tag").Value = "tr"
Set trContent = Browser("Change Management - SAP").Page("Change Management - SAP").ChildObjects(oDesc)
TRSum = trContent.Count()

For i = 0 To TRSum - 1
    Set objPage = trContent(i).Object
    Set objTag = objPage.GetElementsByTagName("td") 
    spanSum = objTag.Length - 1

    For intCtr = 0 to spanSum
            strLink = objTag(intCtr).InnerText
            If strLink = text Then
                 trContent(i).Object.click()
            End If 
     Next   
Next
Set  oDesc=nothing

End Sub

While I have tested, and the with inner element Select All could be recognized, I could not perform an action (like click), and in fact, the code: trContent(i).Object.click() seems having no effect.

Does this have anything to do with the listener/event handler place? such as the listener is not is the TR or TD element?

2

There are 2 answers

2
Torrence On BEST ANSWER

I tried totally four method to trigger the click event listener: 1. QTP recognization: Just Using the TO contained in Object Repositery, and .click to fire the click listener. No Response; 2. Using the SendKeys method: It works in this Action, while when I called the Action from my main action, it does not work; 3. Using DOM call: Just as the scripts above in the question, I could not fire the click handler;

Finally, I turned to the devicereplay. The idea get the element's run time position, and click on that position. This is somehow low level function, and it runs smoothly for my part. Here is my working script:

Set objReleaseTR = Browser("Change Management - SAP").Page("Change Management - SAP_3").WebElement("Release all Transport")

Set objDeviceReplay = CreateObject("mercury.devicereplay")

x = objReleaseTR.GetROProperty("abs_x")
y = objReleaseTR.GetROProperty("abs_y")

objDeviceReplay.MouseClick x + 5, y + 5, 0

Set objDeviceReplay = nothing

Hope this could be helpful for guys that encounter the same problem.

1
MansoorShaikh On

First validate if you have a click listener attached to it or not. It is needed.

You can try the below code trContent(i).Object.FireEvent("onclick")