Sign in to follow this  
Followers 0
DelStone

Frustrating! Cannot click tags <a> and <input> that have an onclick

7 posts in this topic

Hi,

I'm having problems clicking two elements on the following html page.

I've tried linkclicks and formsubmit and read the posts saying use _IEAction - I can't seem to get any of them to work.

I'm having to resort to using send with tabs and enter which breaks quite easily and is really inappropriate for the task at hand...

Can anyone spot what I'm doing wrong?

<form method="post" action="/addfriend.php?id=1592841959&amp;hf=friend_other" onsubmit="return Event.__inlineSubmit(this,event)">
<input type="hidden" autocomplete="off" id="post_form_id" name="post_form_id" value="82f51aa55cbff4b198d4b5ec4ed4ad43" />
<div id="addMsg"><p>
<a href="#" onclick="show('addMsgBox'); hide('addMsg'); return false; ">[ Add a message ]</a>
</p></div>
<div id="addMsgBox" style="display:none; margin-left: 10px;">
<div class="add_personal_message" style="margin-bottom: 4px;">
Add a message:&nbsp;
<a href="#" onclick="hide('addMsgBox'); show('addMsg'); return false;">Cancel</a>
</div>
<textarea onkeyup="textLimit('message',255,'message_msg');" id="message" name="message" class="textarea" cols="30" rows="3" style="width: 250px;" onfocus="" onblur=""></textarea>
<br/><span id="message_msg" style="display: none;"><small>Keep it under 255 characters.</small></span></div>
</div>
<div class="buttonbox">
<input type="submit" class="inputsubmit" onclick="var w = add_to_friend_list_widget.dict[&quot;1592841959&quot;];var d = w.get_form_data();for(k in d) { var i = document.createElement('input');i.type=&quot;hidden&quot;;i.name=k;i.value=d[k];this.form.appendChild(i);};return true;" id="add" name="add" value="Add Friend" />&nbsp;&nbsp;
<input type="button" class="inputbutton inputaux" onclick="history.go(-1);return true" id="cancel" name="cancel" value="Cancel" />
</div>
</form>

My current Autoit code which is not working:

$add_btn = _IEGetObjById($ie, 'add')
_IEAction($add_btn, "click") ;does not work

$colTags = _IETagNameGetCollection($ie, "input")
For $oTag In $colTags
  If StringInStr($oTag.value,"Add Friend") Then
    $hwnd = _IEPropertyGet($ie, "hwnd")
    _IEAction($oTag, "focus")
    ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server;INSTANCE:1]", "{Enter}") ;does not work

    _IEAction($oTag, "click") ;does not work

    ExitLoop
  EndIf
Next

$id = _IEGetObjByName($ie, 'message')
_IEFormElementSetValue($id, $message) ;works

Share this post


Link to post
Share on other sites



You might want to try _IEFormGetCollection and _IEFormElementGetCollection and then address the button as a member of the collection.

Share this post


Link to post
Share on other sites

Hi Chris

I had tried that as well - the result was the same - the elements are not selected or clicked... :)

There is something untoward - as I have never had any problems with other onclick statements before... the _IEAction has always worked - whether it was through using a collection of tags or collection of forms/elements... I'm not sure why there is a problem this time.

Share this post


Link to post
Share on other sites

It has Java function in it ,so most likely you need to fire the onclick event - $element.FireEvent("onclick") or try executing the Java directly - "history.go(-1);return true" for example

Share this post


Link to post
Share on other sites

If you are using IE9, might be the explanation.

Use my _SetIE8() function in that post and try it again. :)


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

Hi

Thanks for the suggestions. Using $element.FireEvent("onclick") does nothing like the alternatives I've tried above.

I can't execute the java directly (or can I) given it comprises:

<input type="submit" class="inputsubmit" onclick="var w = add_to_friend_list_widget.dict[&quot;1592841959&quot;];var d = w.get_form_data();for(k in d) { var i = document.createElement('input');i.type=&quot;hidden&quot;;i.name=k;i.value=d[k];this.form.appendChild(i);};return true;" id="add" name="add" value="Add Friend" />&nbsp;&nbsp;

Share this post


Link to post
Share on other sites

If you are using IE9, might be the explanation.

Use my _SetIE8() function in that post and try it again. :)

That worked - thank you very very much!!!

I have been on this one problem for 3 days - and I can't believe it's such a simple fix! Once again thank you v much.

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