There are instances where clicking on an object within your application doesn't work the way you expect. Maybe the web element you're trying to click on is hidden behind another object. Or, perhaps it's just not visible on the page.
As you know, it's always frustrating. But, in such cases, you can use the FireEvent QTP method to interact with the element.
So, don't let a faulty click get in the way of your testing. Read on for more details!
INDEX
Why Won't the FireEvent Work?
The FireEvent Description
QTP FireEvent Syntax
Valid FireEvent Events
How to Use the FireEvent Video Example
Know FireEvent Issue
Why Won't the FireEvent Work?
While using QTP’s click method on a search WebElement earlier today, I had an issue with the WebTable’s populate event not being triggered as it should have. If you ever experience a similar problem with your application (not performing an expected action after a certain event), don’t give up – and try the FireEvent method.
FYI if you're having issues with quick test professional or unified functional test and it's a custom control, you might want to check out my post How to Build Your Own Custom Control Code.
The FireEvent Description
The FireEvent method is designed to trigger events in an application. Besides that, you can use it when a click does not work. It is also important to note that the FireEvent method will work differently depending on your browser.
QTP FireEvent Syntax
The Syntax for the FireEvent is:
yourObject.FireEvent EventName,[x-optional],[y-optional],[BUTTON-optional]
Valid FireEvent Events
The events available when using the FireEvents method are:
- onchange
- onclick
- ondblclick
- onblur
- onfocus
- onmousedown
- onmouseup
- onmouseover
- onmouseout
- onsubmit
- onreset
- onpropertychange
How to Use the FireEvent Video Example
Let’s take a look at the FireEvent in action in a real-world example:
The click method below was not working:
Set mainPath = browser("CB").Page("CB") mainPath.WebElement("Search").Click
…but using the FireEvent did work:
mainPath.WebElement("Search").FireEvent "ondblclick"
Drop me a line and let me know if you find this tip helpful!
Know FireEvent Issue
If you're trying to use the FireEvent’s dblclick option on a WebElement, but it's not working against Chrome or Firefox, check out:
QTP – Fix for FireEvent Issue in Google Chrome and Firefox Browsers
i have tool tip object when i am taking the mouse to that icon it is giving the value but when i am using the spy it is not having values and i have used the following code
Browser(“Product Zone – FXSpot”).Page(“Product Zone – FXSpot”).WebElement(“WebElement”).FireEvent”onmouseover”
wait 1
ToolTip = Window(“nativeclass:=tooltips_class32”).GetROProperty(“alt”)
msgbox ToolTip
praveen » Hi sorry for the late reply – did you figure this our yet? I have the same code that works excepts I use the GetRoProperty(“text”) property instead of alt. I also use a .Mouse move with the tooltips coordinates.
I am Getting following error –
Failed to run the test due to an unknown error.
For line-
Line (17): “Browser(“Test Home”).Page(“Add Home Standard”).Frame(DatePicker).webtable(“M”).Link(“name:=” + “&16″).Click”
I am using QTP 10.0 and trying to select a date from the calendar on a sharepoint based application.
Although, it opens the calendar and points to the date as 16 Feb 2012, but is not able to select and capture the date in the desired box.
Please let me know the correct syntax for capturing the DATE from the calendar.
Sim » Hi-Have you tried using the webtable(“M”).GetCellData(r,c) method?
Hi Joe.
I’ve updated the code for the date picker line for the calendar now :
From
Browser(“ABC Home”).Page(“Add Standard”).Image(“Select a date from the”).Click 10,5
‘Browser(“ABC Home”).Page(“Add Standard”).Frame(“DatePicker”).webtable(“M”).webelement(“Date”).FireEvent(“onmouseclick”)
to
Browser(“ABC Home”).Page(“Add Standard”).Image(“Select a date from the”).Click 10,5
Browser(“ABC Home”).Page(“Add Standard”).Frame(“Frame”).webtable(“M”).webelement(“Date”).FireEvent(“onmouseclick”)
and it still shows –
The “Frame” object was not found in the Object Repository.
Check the Object Repository to confirm that the object exists or to find the correct name for the object.
Check the Object Repository to confirm that the object exists or to find the correct name for the object.
Line (16): “Browser(“POLO Home”).Page(“Add Policy Standard”).Frame(“Frame”).webtable(“M”).webelement(“Date”).FireEvent(“onmouseclick”)”.
Although, it opens the Calendar in that frame and highlights today’s date,
but is not able to selects the date and fill the required field fro the date by picking from the calendar.
Please suggest.
Hi Joe,
Ur video is very helpful, but can u please tell me what to do if GetROProperty(“Outertext”) is blank. Does that mean the object is not recognized? & how to solve that issue?
waiting for ur suggestion. Thanks
Poonam » Hi-When you spy on the object does the Outertext property have a value?
Hi Joe,
Thanks for the reply, i will give u some more details about the same issue.
1) Application used is .net
2) There is noOutertext property seen through object spy
3) I could record the code properly, when executed in Debug mode the data is getting added in the table (something similar like ur video shown above about ‘Search’ button and data
population). But the issue comes when i RUN the script. The button is getting clicked properly but the data which should be added in a table after the click, is not getting added.
4)SwfWindow(“TOM”).SwfWindow(“SwfWindow”).SwfWindow(“TOM_Amount Details”).SwfObject(“btnSave”).Click 83,19
Other method tried is
x= SwfWindow(“TOM”).SwfWindow(“SwfWindow”).SwfWindow(“TOM_Amount Details”).SwfObject(“btnSave”).GetROProperty(“enabled”)
msgbox x ((Here x gives proper value TRUE))
SwfWindow(“TOM”).SwfWindow(“SwfWindow”).SwfWindow(“TOM_Amount Details”).SwfObject(“btnSave”).Click 83,19
Click is also happening, but no data is added.
Waiting for ur reply
Hi Again,
some more info :
Tried using FireEvent “onclick” the follwing way,
SwfWindow(“TOM”).SwfWindow(“SwfWindow”).SwfWindow(“TOM_Amount Details”).SwfObject(“btnSave”).FireEvent “onclick”
But no luck, it gave me Exception Occured error.
Please help
Thank you so much for the suggestion. the code is working accordingly using FireEvent on webelement.
Pratibha Pawar » Cool!
Hi ,
Please see the below script,which I recorded.
Browser(“Welcome to the website”).Page(“Date”).Frame(“ContentIFrame”).Image(“img_calendar”).Click
Browser(“Welcome to the website”).Page(“Date”).Frame(“ContentIFrame”).Link(“17”).Click
In the above script , I need to select current date for each run.Can anyone provide me suggesstion , how to get current date, as the date is displayed as link.I am confused little bit
Plz give it in Descriptive programming
Note:1.Only able to select the date.Not able to enter manually.
Hi Joe,
Mine is similar to the video. Here I have weblist & upon selection data should populate in webtable. I tried below but does not work.
Browser(B).Page(P).WebList(wl).Object.FireEvent “onchange”
Browser(B).Page(P).WebList(wl).Select data
Browser(B).Page(P).WebList(wl).Object.FireEvent “onchange”
I tried with & without .object.FireEvent. Pls help to resolve this.
HI, How to Write a code for to select one child link of floating Menu( if menu have multiple Links)
srikanth » Any chance you could give me an example of a floating menu? When you spy on it what is it’s nativeclass?
hi joe,
i need to validate excel sheet icon and the color of the insert work paper which will be in navaigatoin bar in application which i am automating with QTP , silver-light add-in how to do this any suggestions from your end would be helpful for me
Hi Joe,
earlier i have used qtp 11 and capture the object as swfedit for dotnet 3.5 version application. Now i have upgraded to UFT 11.5, now the same object is recognized as swfobject. could you please let me know if you have solution for this
Baskar » Not sure why this is happening.
Dumb question – are you sure the .NET add-in is selected when you start UFT?
What version of UFT do you have installed? HP did release a critical service pack 11.51 for UFT (UFT_00001) that they recommend everyone install. If you don’t have the SP I would start there.
Also I double checked HP’s KB and did not find any known issues with UFT and .net 3.5. You might want to also contact HP support and check to see if there are any known issue or hot fixes that will resolve this for you.
Hi Joe,
I wanted to hover my mouse on a link in Nav bar, as after hovering there are many links and I need to get child objects from that.. How do I do?
I have the same question.
I am trying to Click on 100 links putting them through a For Loop but it is not working after flirt round when it goes back for second round it throws a General error . please help
Aminul » Can you show us your code?
I am trying to capture the tooltip of Weblist which is placed on a table. the below code is not working consistently. Please suggest some alternative. please find the code
Set pS = Browser(“Browser”).Page(“page”).Frame(“frame”).WebTable(“WebTable”).ChildItem(2,5, “WebList”, 0)
pS.MouseOver
wait 1
actualErrorText= Window(“nativeclass:=tooltips_class32”).GetROProperty(“text”)
Hi Joe,
I have appreciate your replay on testing question ,
Please help me script how to select a folder and right click then verify cut button is disable ,where two cut items is present menu.
Hi Joe,
i am trying to click a webelement which in the last row of a table. Each row of this table is a webtable itself and not a row and i need to be able to click on specific “webelement”. I tried firevent onclick and ondblclick but its doesnt work.
1) This code based on index value works but i dont want to use index value.
i = 0
Browser(“Admin”).Page(“SearchMain”).WebElement(“class:= ux-icon-action”, “html tag:= DIV”, “index = i”).Click
2) None of the below option works
Set Icon1 = Browser(“Admin”).Page(“SearchMain”).WebTable(“Table-2″).ChildItem(1,16,”WebElement”,0)
Icon1.Click
Icon1.fireevent “ondblclick”
Icon1.fireevent “onclick”
Could you help me with this. thanks
correction i meant icon that i have to click is a webelement which is present in the last column of row.
WHy u people using Window class in the web based application that is genuine it fire error better use fire event and pass the appropriate event name ,,sorry for too late replay
hi friends,
I am trying to click on webelement but its not happening with below code,,
Browser().page().WebElement(“”).click
Browser().page().WebElement(“”).FireEvent “ondblclick”
Browser().page().WebElement(“”).FireEvent “onclick”
and i changed replay type to “mouse” but still clicking is not happening…can u please suggest me
Thanks in advance
Hi Joe,
Mine is a pega application.In this i have a screen where i have to double click and select the web element from the list and it gets autpopulated in the fields.I ahve tried using the firevent and web conf settings.no use..
Your reply is highly appreciated
Hi Joe,
By seeing the above comments in the discussion, I could say that there is no solution provided to Mr.Sim’s Date Picker Problem.
I too have the same problem, I have to select the date using Day(Now) func. which would be varying time to time,
Have tried all the above methods including Fireevents, Hmmmm No Luck, Could You help me with the same??
My Script’s as Below:
Function
Dim a,b,c
Public Function clickelement(a,b,c) Browser(a).Page(b).WebElement(c).Click/FireEvent(“onmouseclick”)/FireEvent “onclick”
End Function
clickelement “Home”, “Book Appointment “, day(Now)
W8ing for a solution :)
Hi I am working with online AAA fuel cost calculator and somehow just not able to create code to select “start city” from the dropdown weblist. I did a record and reran the script. It fails to select an item from the weblist saying it can’t ID the object “DDStartCity” of class (“Weblist”). I then tried Add object to local and created a script but again same error . I tried the Fireevent mtd u gave again same error. I did a msgbox to chk if the correct value is getting picked through Getitem . it does pick the correct value but it doesn’t select it from the weblist. PLS HELP in coding this
Hi,
I am trying to click webtable link. I have tried most of the options, but no luck. Pls some help me on this
Webtable link highlights correctly but its not clickable
Here is my code
Set oWebTable = Browser(“”).Page(“”).WebTable(“Class Name:=WebTable”, “column names:=Farm Number;Tract Number;Scenario Description;Program Year;Offer Status;Offered Acres;State/County Physical Location;”,”html tag:=TABLE”,”name:=View”)
linkcount = oWebTable.ChildItemCount(3,9, “Link”)
If oWebTable.Exist Then
linkname =oWebTable.ChildItem(3,9, “Link”,0).GetROProperty(“text”)
urlname =oWebTable.ChildItem(3,9, “Link”,0).GetROProperty(“url”)
oWebTable.ChildItem(3, 9, “Link”, 0).Highlight
oWebTable.ChildItem(3, 9, “Link”, 0).Click
Browser(“”).Page().WebTable(“Class Name:=WebTable”, “column names:=Farm Number;Tract Number;Scenario Description;Program Year;Offer Status;Offered Acres;State/County Physical Location;”,”html tag:=TABLE”,”name:=View”).Link(“Class Name:=Link”,”html tag:=A”,”name:=Submit To COC”, “url:=”&urls).FireEvent “onclick”
oWebTable.ChildItem(5, 9, “Link”, 0).FireEvent “micMousePress”
End If
U use Childitm(row,column,”micclass’,index) to find the specific data which is present in webtable. thankx
I want to double click on a row in a JAVATABLE I tried below , but failed. Please help me.
1> Using mercury device replay
it’s able to click the row,but not able to double click
2> Using fireevent “ondblclick”
it say operation can not be performed.
now I will write the code
1> set mouse= CreateObject(“Mercury.DeviceReplay”)
mouse.mousemove x,y ‘ fine
mouse.mouseclick x,y,button’ fine
mouse.mousedblClick x,y,button ‘does not work ! WHY??/
2> JavaWindow().JavaInternalFrame().JavaTable().fireEvent “ondblclick”
gives error operation can not supported..
Pls help me
JavaWindow().JavaInternalFrame().JavaTable(). doubleClickCell 3,3
It says
Error Message- Operation can not be performed. However when I do .(dot) at javatable I can see doubleClickCell method in the intellisence.
UFT 11.53
JAVA 1.3.1.25
If you create a quick record script does it recognize and dbl click on the java table? Is this a custom control? Worst case scenario can you use the insight record option in UFT
Hi Joe,
I need to use QTP for sharepoint application automation. Is it possible?
Can you please suggest your opinion on this.
Hi Joe,
Hi,
I have the below code. It supposed to double click “test” folder but it just select the folder instead. How can I double click the test folder so I can select a file inside the test folder?
Dialog(“Save current report in”).WinObject(“Items View”).WinList(“Items View”).Select “test”
Thanks.
Works great, many thanks for the help. We have a Win7 machine with UFT 11.5 and IE v8, and it couldn’t invoke a certain image link using the “click” method, though was fine when invoking other image links in the same way. We didn’t see this problem with another machine running IE v10.
Awesome – glad it worked for you!
Thanks man, this is usefull.
Hi, I just wanted to ask if there is a way to get the HTML Element x and y position/coordinates using VBA
ex:
for each td in ie.document.getelementsbytagname(“td”)
if td.innertext = “ThisElement” then
x = elem.positionx (just a sample)
y = elem.positiony (just a sample)
end if
next td
I am working on of the web application. However I am unable to click in link even after able to highlight successfully. Click method is not working on this object. Please assist.
Code Used:
Browser(“Brwoser”).Page(“Page”).WebElement(“WebelemenProperties”).Highlight ””’ Im able to highlight
Browser(“Brwoser”).Page(“Page”).WebElement(“WebelemenProperties”).Click ”’ Click method is not working
Browser(“Brwoser”).Page(“Page”).WebElement(“WebelemenProperties”).FireEvent “onClick” ”’ This also not working
What to do when FireEvent is not working when inside the loop?