Iceburg Posted August 7, 2009 Share Posted August 7, 2009 I am having a terrible time selecting and submitting a Radio button in IE... I have read this: http://www.autoitscript.com/forum/index.php?showtopic=98859&st=0&p=710690&hl=IE%20radio%20button&fromsearch=1&#entry710690 Using this code, I think I have the correct form, here is the code I used, and console output. For $oInput in $oInputs consolewrite(string($oInput.id) & @CRLF) Next --> IE.au3 V2.4-0 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch --> IE.au3 V2.4-0 Error from function _IEFormElementRadioSelect, $_IEStatus_InvalidDataType buddy_list_typeahead_input post_form_id q init 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 The source code looks like this: expandcollapse popup</center> <div class="herror bb"> <form method="post" action="/fishwrangler/my" id="app8138090269_form_4a7860e76da474951097713"><input type="hidden" name="fb_sig_locale" value="en_US" /><input type="hidden" name="fb_sig_in_new_facebook" value="1" /><input type="hidden" name="fb_sig_time" value="1249403111.4478" /><input type="hidden" name="fb_sig_added" value="1" /><input type="hidden" name="fb_sig_profile_update_time" value="1244918738" /><input type="hidden" name="fb_sig_expires" value="1249408800" /><input type="hidden" name="fb_sig_user" value="1533592366" /><input type="hidden" name="fb_sig_session_key" value="2.Yq1Iz3uxWaYkVDj9MVNsng__.3600.1249408800-1533592366" /><input type="hidden" name="fb_sig_ext_perms" value="auto_publish_recent_activity" /><input type="hidden" name="fb_sig_api_key" value="5d768d28d2f2bc00fd5c1e5bb66652c5" /><input type="hidden" name="fb_sig_app_id" value="8138090269" /><input type="hidden" name="fb_sig" value="7cf30373adcce37790943a9588b80e7a" /> <div class="pad"> <table width="100%"> <tr> <td width="205px"> <img class="i2 brdr" src="http://72.2.118.86/images/v2/enemy/polar-bear.jpg" alt="Polar-bear" /><br /> </td> <td> <h2 class="red bold" style="text-align: left;"> What do you want to do?</h2><br /> <table><tr><td> <label><input type="radio" name="option" value="stay" /> Slowly walk back and hide in my tent. </label> <br /><br /></td></tr><tr><td> <label><input type="radio" name="option" value="leave" /> Take off and run. </label> <br /><br /></td></tr> <tr><td> <label><input type="radio" name="option" value="give" /> Offer it my next few catches. <span class="tiny red">(depends on the Polar Bear's hunger)</span> </label> <br /><br /></td></tr> <tr><td> <label><input type="radio" name="option" value="alt" /> Scare it with the Massavior Addon! <span class="tiny red"> (works best with a level 88+ Holy Liberator) </span> </label> <br /><br /></td></tr> <tr> <td> <input type="submit" value="Submit" class="inputbutton" /> Currently I have: $oForm = _IEFormGetCollection ($oIE, 2) _IEFormElementRadioSelect ($oForm, 3, "Option", 1, "byValue") And its not selecting anything... and is not trying to submit anything. I've read up on the help file, and I cause I am having a hard time matching the source code HTML up to the example. Link to comment Share on other sites More sharing options...
Juvigy Posted August 7, 2009 Share Posted August 7, 2009 Which radio button do you want to select? The third one? As your second parameter is ID but the radio buttons in your code dont have ID. Link to comment Share on other sites More sharing options...
Iceburg Posted August 7, 2009 Author Share Posted August 7, 2009 (edited) Which radio button do you want to select? The third one? As your second parameter is ID but the radio buttons in your code dont have ID. The last one, I think its called "alt" Is it 0,1,2,3 so its the 3rd, or is it 1,2,3,4 and the 4th? So this? $oForm = _IEFormGetCollection ($oIE, 2) _IEFormElementRadioSelect ($oForm, "alt", "Option", 1, "byName") Edited August 7, 2009 by Iceburg Link to comment Share on other sites More sharing options...
Iceburg Posted August 7, 2009 Author Share Posted August 7, 2009 How do i submit the form as well then? I don't think its working, but i will try it. Link to comment Share on other sites More sharing options...
DaleHohm Posted August 7, 2009 Share Posted August 7, 2009 What you have would work if you used byIndex instead of byValue, or change the 3 to "alt". You can try _IEFormSubmit, but you may want to get a reference to the submit button and then use _IEAction, click Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
Iceburg Posted August 8, 2009 Author Share Posted August 8, 2009 Didn't work, it didn't select the button, and didn't submit. What else should I do / try? I am confused. Link to comment Share on other sites More sharing options...
DaleHohm Posted August 8, 2009 Share Posted August 8, 2009 Didn't work, it didn't select the button, and didn't submit. What else should I do / try? I am confused.If you are confused, then spend some time with the examples in the helpfile for _IEFormElementRadioSelect first. Run them, modify them, figure out what makes your situation different. Then, if still having trouble, come back here with much more specific questions (and please read my sig regarding "Doesn't work").Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
Iceburg Posted August 8, 2009 Author Share Posted August 8, 2009 If you are confused, then spend some time with the examples in the helpfile for _IEFormElementRadioSelect first. Run them, modify them, figure out what makes your situation different. Then, if still having trouble, come back here with much more specific questions (and please read my sig regarding "Doesn't work"). Dale Sorry, that was some frustration that was coming out there. Okay, so here is what I have: $oForms = _IEFormGetCollection ($oIE) $iNumForms = @extended MsgBox(0, "Forms Info", "There are " & $iNumForms & " forms on this page") For $i = 0 to $iNumForms - 1 $oForm = _IEFormGetCollection ($oIE, $i) MsgBox(0, "Form Info", $oForm.name) Next Returns two things: "Universal Search Box" and "0" The search box is a standard search box on the page, so I can only assume that I need to work with the form "0" So... Reading the help file, and running through the examples, I have tried these: expandcollapse popup$oForm = _IEFormGetCollection ($oIE) _IEFormElementRadioSelect ($oForm, 0, 0, 1, "byValue", 1) _IEFormSubmit ($oForm) _IELoadWait ($oIE) $oForm = _IEFormGetCollection ($oIE) _IEFormElementRadioSelect ($oForm, "alt", 0, 1, "byValue", 1) _IEFormSubmit ($oForm) _IELoadWait ($oIE) $oForm = _IEFormGetCollection ($oIE) _IEFormElementRadioSelect ($oForm, 3, 1, 1, "byIndex", 1) _IEFormSubmit ($oForm) _IELoadWait ($oIE) $oForm = _IEFormGetCollection ($oIE) _IEFormElementRadioSelect ($oForm, "alt", 0, 1, "byname", 1) _IEFormSubmit ($oForm) _IELoadWait ($oIE) $oForm = _IEFormGetObjByName ($oIE, "Option") _IEFormElementRadioSelect ($oForm, 0, 0, 1, "byValue", 1) _IEFormSubmit ($oForm) _IELoadWait ($oIE) $oForm = _IEFormGetObjByName ($oIE, "Option") _IEFormElementRadioSelect ($oForm, "alt", 0, 1, "byValue", 1) _IEFormSubmit ($oForm) _IELoadWait ($oIE) $oForm = _IEFormGetObjByName ($oIE, "Option") _IEFormElementRadioSelect ($oForm, 3, 1, 1, "byIndex", 1) _IEFormSubmit ($oForm) _IELoadWait ($oIE) $oForm = _IEFormGetObjByName ($oIE, "Option") _IEFormElementRadioSelect ($oForm, "alt", 0, 1, "byname", 1) _IEFormSubmit ($oForm) _IELoadWait ($oIE) So, mostly trial and error, but trying to figure out where I went wrong... $oForms = _IEFormGetCollection ($oIE) $iNumForms = @extended MsgBox(0, "Forms Info", "There are " & $iNumForms & " forms on this page") For $i = 0 to $iNumForms - 1 $oForm = _IEFormGetCollection ($oIE, $i) ConsoleWrite("Form Info " & $oForm.name & @CRLF) Next returns: Form Info universal_search_form Form Info 0 $oForm = _IEFormGetCollection ($oIE, 0) ConsoleWrite("(" & _Now() & ")" & $oForm & @CRLF) $oQuery = _IEFormElementGetCollection ($oForm, -1) ConsoleWrite("(" & _Now() & ")" & $oQuery & @CRLF) Returns: (8/8/2009 12:03:35 PM) (8/8/2009 12:03:35 PM) My questions: 1.) Am I even using the correct functions to reference the Radio buttons? 2.) Is "0" what I use for my $s_string Value, or what is an $s-string value. Help file says: used to match element - treatment based on $s_mode, but I don't know what that is in my example. Link to comment Share on other sites More sharing options...
Iceburg Posted August 9, 2009 Author Share Posted August 9, 2009 Anyone else have any ideas / suggestions besides Dale? Link to comment Share on other sites More sharing options...
Juvigy Posted August 10, 2009 Share Posted August 10, 2009 here you go: #include <IE.au3> $oIE=_IECreate("C:\test2\123.html") $oDoc = _IEDocGetObj($oIE) $oArray = $oDoc.getElementsByTagName ("input") for $element in $oArray if $element.value="alt" Then $element.checked=true next Just put the site name in _IECREATE Link to comment Share on other sites More sharing options...
Iceburg Posted August 10, 2009 Author Share Posted August 10, 2009 I still don't have it working... Man, radio buttons are difficult for me! $oDoc = _IEDocGetObj($oIE) $oArray = $oDoc.getElementsByTagName ("input") for $element in $oArray if $element.value="alt" Then $element.checked=true next $oLForm = _IEFormGetCollection($oIE, 0) _IEFormSubmit($oIE) _IELoadWait($oIE) sleep(2000) Returns: --> IE.au3 V2.4-0 Error from function _IEFormSubmit, $_IEStatus_InvalidObjectTypeC:\Documents and Settings\Owner\Desktop\fish.au3 (77) : ==> Error parsing function call.: Am I supposed to submit the form different when doing with the object? Link to comment Share on other sites More sharing options...
Juvigy Posted August 11, 2009 Share Posted August 11, 2009 For submitting try this: #include <IE.au3> $oIE=_IECreate("C:\test2\123.html") $oDoc = _IEDocGetObj($oIE) $oArray = $oDoc.getElementsByTagName ("input") for $element in $oArray if $element.value="alt" Then $element.checked=true next for $element in $oArray If $element.Value = "Submit" Then _IEAction($element, "click") next Link to comment Share on other sites More sharing options...
Iceburg Posted August 11, 2009 Author Share Posted August 11, 2009 you rock, thats exactly what worked. You can spam me anytime. =) Link to comment Share on other sites More sharing options...
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