In QTP11, I have a function as below to handle a drop-down list button. The HTML structure is as follows:
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?
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:
Hope this could be helpful for guys that encounter the same problem.