Jump to content

Execute JavaScript Event using FF.AU3


Recommended Posts

I'm trying to simulate a click on a button using FireFox (FF.AU3), but no success in these last few days :(

This is the source code of the page:

<a href="#" class="btn btn-sm btn-green" id='superbutton' onclick="kickme(event,'ids11')" > <span class="icon"><i class="super-icon"></i></span> <span id='superbutton'>&nbsp; ClickMe</span> </a>

Tried with no success:

_FFClick("superbutton", "id")
_FFClick("btn btn-sm btn-green", "class", 0)

That "0" index also already replaced by other numbers (in order to do a try and error approach).

The _FFLinkClick result below looks promising:

_FFLinkClick("ClickMe", "text")

__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//a[contains(.,'ClickMe')]",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: http://thisistheweb.com/thepage# - {toString: function() {...}, target: "", download: "", ping: "", rel: "", relList: {...}, hreflang: "", ...}
__FFSend: try{FFau3.simulateEvent(FFau3.xpath,'MouseEvents','click');}catch(e){'_FFCmd_Err';};
__FFRecv: 1

Seems it found the button and click it, but in fact: it doesn't. Or maybe it did click it, but the result is totally different with if I click the button manually.

So...

I'm thinking if I cant simulate a click on the button, I should execute the JavaScript onclick event.

But... how?

Thanks a lot :)

Link to comment
Share on other sites

  • 3 months later...
On 20/10/2015 at 7:29 AM, Danp2 said:

Have you tried this?

_FFXPath( "//input[@id='superbutton']")
_FFCmd("FFau3.xpath.onclick()")

 

Thanks a lot, Danp2 :)

I guess that will work, but finally I got it work perfectly using this code before tried _FFCmd above:

$oInput = _FFXPath('//*[@id="superbutton"]')
Sleep(500)
_FFDispatchEvent($oInput, 'keypress', 13)

Hope it help everyone who face a similiar problem.

Thanks, again!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...