QTP – How to use the FireEvent method when a click does not work

QTP/UFT Published on:
Fire

While using QTP’s click method on a search WebElement earlier today, I had an issue with a 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 occurs), don’t give up – and be sure to try the FireEvent method.

What is the FireEvent Description:

The FireEvent method is designed to trigger events in an application.

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 your trying to use the FireEvent’s dblclick option on a WebElement but its not working against Chrome or FireFox  check out

QTP – Fix for FireEvent Issue in Google Chrome and FireFox Browsers

44 responses to “QTP – How to use the FireEvent method when a click does not work”

  1. 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.

  2. 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.

  3. 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.

  4. 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

  5. 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

  6. 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

  7. 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.

  8. 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.

  9. 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

  10. 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.

  11. 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?

  12. 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

  13. 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”)

    • 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

  14. 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.

  15. 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

  16. 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

  17. 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

  18. 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 :)

  19. 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

  20. 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

  21. 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

  22. 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

  23. 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.

  24. 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.

  25. 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

  26. 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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Fire