What to do when Dropdown object is recognized as WebElement by QTP?


Many times we come across some web applications where the dropdown object is been recognized as “WebElement” object instead of “WebList” object. No worries, I have a simple solution for that for you.

1.  Copy Paste this piece of code in your function library (For example Test.qfl)

Public Function ListShellSendKeys(ByRef webEdit, ByRef textVal)
            Set WshShell = CreateObject("WScript.Shell")
            wait 0.10
            webEdit.Click
            WshShell.SendKeys(textVal)
            wait 0.20
            webEdit.Click
            wait 0.20
            Set WshShell = nothing
End Function
RegisterUserFunc "WebElement", "ShellSendKeys", "ListShellSendKeys",False

2.Associate the Test.qfl with your current test

      3. Use the function J

Browser("IE").Page("Example").WebElement("Country").ShellSendKeys "Canada"

Comments

Popular posts from this blog

How to maximize FireFox browser from QTP

How to search and click a link in a WebTable?

How to take screenshot of failed QTP step?