in reply to Re^3: Is it possible to trigger a mouse click action in a browser using Perl?
in thread Is it possible to trigger a mouse click action in a browser using Perl?

Unfortunately the click() method only works on input elements,

Where do you get that idea? click Method (A, ADDRESS, APPLET, ...)

  • Comment on Re^4: Is it possible to trigger a mouse click action in a browser using Perl?

Replies are listed 'Best First'.
Re^5: Is it possible to trigger a mouse click action in a browser using Perl?
by james2vegas (Chaplain) on Aug 14, 2009 at 11:32 UTC
    From the DOM HTML Level One Spec, where click() is

    click: Simulate a mouse-click. For INPUT elements whose type attribute has one of the following values: "Button", "Checkbox", "Radio", "Reset", or "Submit".
    This method has no parameters.
    This method returns nothing.
    This method raises no exceptions.
    at
      That is hysterical. If you go strictly by the RFC, you would use dispatchEvent, but since you are using Microsoft Windows OLE Automation use
      $obj->fireEvent("onclick");
        Yes, Microsoft is not known for following standards. The OP indeed can use the click method to browse to those links as Microsoft extends the functionality of click() to other, non-INPUT elements. I have to concede that I foolishly thought Microsoft would follow the standards their own documentation links to.

        fireEvent is a method in Microsoft's DOM, not something specific to OLE Automation, and from what I can tell it doesn't perform the default action of the event on the element (in the case of AnchorElement->onclick, browsing to href), just any custom event handlers attached to event on that element. So if the OP's page had a:hrefs like 'javascript:.*' instead of onclick handlers, using fireEvent would not work for them.