Sign in to follow this  
Followers 0
michaelslamet

Execute JavaScript Event using FF.AU3

3 posts in this topic

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

Share this post


Link to post
Share on other sites



Have you tried this?

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

 

1 person likes this

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • milos83
      By milos83
      How can I check if element is focused in Firefox using FF.au3 UDF?
      This is my try:
      I have prepared a function that checks if the object is focused:
       
      _FFCmd('FFau3.isfocused=function isfocused(a){try{return (a === document.activeElement)}catch(e){return}}') $oElm = _FFXPath("//*[@id='someId']") ConsoleWrite(_FFIsFocused($oElm)) Func _FFIsFocused($sElement = "") Local $isFoc = _FFCmd("FFau3.isfocused(" & $sElement & ")") Return $isFoc EndFunc ;==>_FFIsFocused Now, the javascript part is tested and it does return successfully.
      After a lot of try/fails I inserted an alert box in order to display the object being compared.
      Here is what I got
       
      The focused object is: [object XULElement]
      The object that I send for comparing is [object HTMLInputElement]
      Why is that?
       
       
    • Chimp
      By Chimp
      Hi all.
      I'm playing a bit with the ScriptControl object using as base this example by @genius257.
      here is a very simple try, ... but it fails. what I'm doing wrong?
      Local $oSC = ObjCreate("ScriptControl") $oSC.Language = "JScript" $oSC.ExecuteStatement('alert("I am a javascript alert box!");') MsgBox(0,'AutoIt','Pause') Thanks
    • spuuunit
      By spuuunit
      Is it possible to know if a textbox is active in FireFox?
       
      This is what I want:
      if (Textbox in FireFox == Active) { }
    • steveeye
      By steveeye
      Hi, what else can we add in <table> besides <tr> & <td> to make it more interative to the users?