flyingboz Posted June 21, 2005 Posted June 21, 2005 (edited) Trying to get this button to click....Getting clued in to the fact that this is related to the javascript that is getting called - saw the forum information on using send, is there a way in the COM world to force the execution of the javascript? Global $IE $debug = 1 ;form submit test $url = "http://cs.wellesley.edu/~cs110/thau/Chapter07/fig7-21.html" $ie = ObjCreate("InternetExplorer.Application") $ie.Visible = 1 $ie.Navigate ($url) While Not $IE.busy sleep(50) WEnd $ie.document.the_form.submit.click () Edited June 21, 2005 by flyingboz Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.
scriptkitty Posted June 22, 2005 Posted June 22, 2005 More IE fun like this in scraps to play with. expandcollapse popupGlobal $IE $debug = 1 ;form submit test $url = "http://cs.wellesley.edu/~cs110/thau/Chapter07/fig7-21.html" $IE = ObjCreate("InternetExplorer.Application") $IE.Visible = 1 $IE.Navigate ($url) Do sleep(100) until $IE.readystate = 4 _IE_formclick("score this quiz") Exit ;=============================================================================== ; ; Function Name: _IE_formclick ; Description: Clicks something on a form ; Parameter(s): $_find - text to find ; $_form - Number of form element (optional) ; Requirement(s): $IE must be an IE object ; Return Value(s): On Success - Clicks ; On Failure - no failure yet ; Author(s): scriptkitty ; ;=============================================================================== ; Func _IE_formclick($_find,$_form = 0) For $i = 1 To $IE.document.forms ($_form) .elements () .length - 1 If StringInStr($IE.document.forms ($_form) .elements ($i) .outerHTML, $_find) > 0 Then $IE.document.forms ($_form) .elements ($i) .click() EndIf Next EndFunc AutoIt3, the MACGYVER Pocket Knife for computers.
scriptkitty Posted June 22, 2005 Posted June 22, 2005 here is a bit more, in case you want to do checkboxes, which can be a bit more complicated to fill out. expandcollapse popupGlobal $IE $debug = 1 ;form submit test $url = "http://cs.wellesley.edu/~cs110/thau/Chapter07/fig7-21.html" $IE = ObjCreate("InternetExplorer.Application") $IE.Visible = 1 $IE.Navigate ($url) Do sleep(100) until $IE.readystate = 4 _IE_formcheckbox($IE,"question1"); some text in the HTML code of the item. _IE_formcheckbox($IE,"question2") _IE_formclick($IE,"score this quiz") Exit ;=============================================================================== ; ; Function Name: _IE_formclick ; Description: Clicks something on a form ; Parameter(s): $_ObjIE - IE object ; $_find - text to find ; $_form - Number of form element (optional) ; Return Value(s): On Success - Clicks ; On Failure - no failure yet ; Author(s): scriptkitty ; ;=============================================================================== ; Func _IE_formclick($_ObjIE,$_find,$_form = 0) For $i = 1 To $_ObjIE.document.forms ($_form) .elements () .length - 1 If StringInStr($_ObjIE.document.forms ($_form) .elements ($i) .outerHTML, $_find) > 0 Then $_ObjIE.document.forms ($_form) .elements ($i) .click() EndIf Next EndFunc ;=============================================================================== ; ; Function Name: _IE_formcheckbox ; Description: Marks element as checked on a form ; Parameter(s): $_ObjIE - IE object ; $_find - text to find ; $_form - Number of form element (optional) ; Return Value(s): On Success - marks element as checked ; On Failure - no failure yet ; Author(s): scriptkitty ; ;=============================================================================== ; Func _IE_formcheckbox($_ObjIE,$_find,$_form = 0) For $i = 0 To $_ObjIE.document.forms ($_form) .elements () .length - 1 If StringInStr($_ObjIE.document.forms ($_form) .elements ($i) .outerHTML, $_find) > 0 Then $_ObjIE.document.forms ($_form) .elements ($i) .checked = true EndIf Next EndFunc ;==>_IE_formcheckbox AutoIt3, the MACGYVER Pocket Knife for computers.
flyingboz Posted June 24, 2005 Author Posted June 24, 2005 Brilliant! Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.
g5mike Posted June 24, 2005 Posted June 24, 2005 (edited) <form name="genericForm" method="post" action="/MessagingWeb/buttons.do"><input type="hidden" name="org.apache.struts.taglib.html.TOKEN" value="8f5bf8a2ab49c8e257ebcba074c4808c"> <input type="image" name="refresh" src="/refresh.gif" border="0" alt="refresh"> <input type="image" name="sendMessage" src="/new-enrol-mess.gif" border="0" alt="new enrolment message"> <input type="image" name="send1Message" src="/new-message.gif" border="0" alt="new banking message"> <input type="image" name="search" src="/search.gif" border="0" alt="search"> <input type="image" name="statistics" src="/statistics.gif" border="0" alt="statistics"> <input type="image" name="logOff" src="/exit1.gif" border="0" alt="exit"> </form> Any ideas on how I can click these form elements? I've tried using the UDF scriptkitty made but won't work - prolly due to the mess of the HTML i'm trying to script! Any help would be welcomed. Edited June 24, 2005 by g5mike
g5mike Posted June 24, 2005 Posted June 24, 2005 Maybe it's me idunno but when i do ConsoleWrite($ObjIE.document.forms(1).elements().length) The result is 1 Which is just the 1 form element in form(1) ? I dont seem to be able to get to the input elements.
flyingboz Posted June 25, 2005 Author Posted June 25, 2005 Are you able to provide a public URL that highlights your issue? Remeber these enumeration arrays are zero indexed. Also, try to enumerate the form explicitly (by name), rather than by array index. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.
g5mike Posted June 25, 2005 Posted June 25, 2005 (edited) sorry it's not external and I don't have any wespace set up to show it as it needs apache struts. I tries this ConsoleWrite($ObjIE.document.genericForm.elements(0).name) Andf the result was: org.apache.struts.taglib.html.TOKEN Which is the name of the hidden form element - the rest aren't accesible :-S so like element(1) isn't there - very odd. Could this be due to running IE 5.5 at all? Edited June 25, 2005 by g5mike
g5mike Posted June 25, 2005 Posted June 25, 2005 Big Yay! After reading a few other forums, it seem sthat type="image" is not included in the collection! But.... $ObjIE.document.all.item("statistics").click Works a treat!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now