Testing the departure menu in QTP
I am looking for ideas for triggering actions for dropdowns using QTP.
I am testing a web application using QTP. The application has a "cascading" or hierarchical dropdown menu.
eg. Options->Preferences
During transcoding, QTP recognizes the endpoint in the menu hierarchy (eg "Preferences"). But when running the test, the launch WebElement("Preferences").Click
doesn't work.
If I call Link("Options").FireEvent ("onmouseover")
, it pulls up the menu, after which I can highlight the "Settings" item, but calling a click even after turning off the menu cannot trigger the menu action.
Any ideas for triggering a click action on these menu items would be helpful.
Best regards, ADARSHA
source to share
Due to the loss of multitasking during QTP execution, I have not implemented suggestesiton with Motti. So I came to HTML to see what mouse events are expected from the java script. It turns out I need to call the following sequences:
Link("Options").FireEvent ("onmouseover")
WebElement("Preferences").FireEvent ("onmouseover")
WebElement("Preferences").FireEvent ("onClick")
This trick works really well, but the risk here is that they change something abruptly (say instaed of litening to Click if they use onMouseDown) I need to set up a test script.
source to share
If it Click
does not complete the job, there may be other events awaiting the web application that are not modeled by QTP. One way to get around this is to enable Web Mode Device Play Mode :
Setting.WebPackage("ReplayType") = 2
After this line in the test, when QTP sees a step Click
, it will play it by moving the mouse over the element and simulating a click, so that all events that are triggered by people will be fired.
To return to the default event playback mode, set "ReplayType"
to 1.
source to share
I have another option. use this to click on any object.
Set objMenu = Browser("Browser").Page("Pagel").WebElement("Menu_ELM")
Set objDeviceReplay1 = CreateObject("mercury.devicereplay")
x = objMenu.GetROProperty("abs_x")
y = objMenu.GetROProperty("abs_y")
objDeviceReplay1.MouseClick x + 35 , y + 5,0
Set objDeviceReplay1 = Nothing
source to share
I had a similar situation handled slightly differently, first click on the parent link Options
, then run fireevent onclick
with ordinal id
eg: browser().page().link(options).click
browser().page().link("name:=preferences","html tag:=A","index:=X").firevent "onclick"
This would ideally load the intended parent link and would be useful when triggering a fire event on click. Hope it helps.
source to share