vyper0 Posted April 29, 2009 Posted April 29, 2009 (edited) I am trying to answer a series of questions on a webpage. There are 4 questions each with its own name (A1, A2, A3 and AC). As shown below... <div class='codetop'>CODE</div><div class='codemain' style='height:200px;overflow:auto'> <TR class=bgwhitetext><TD class=bgwhitetext width="70%">1. Do you like apples? </TD> <TD width="20%"><INPUT type=radio CHECKED value=Y name=A1> Yes <INPUT type=radio value=N name=A1> No </TD></TR> <TR class=bgwhitetext><TD class=bgwhitetext width="70%">1. Do you like oranges? </TD> <TD width="20%"><INPUT type=radio CHECKED value=Y name=A2> Yes <INPUT type=radio value=N name=A2> No </TD></TR> <TR class=bgwhitetext><TD class=bgwhitetext width="70%">1. Do you like kiwi? </TD> <TD width="20%"><INPUT type=radio CHECKED value=Y name=A1> Yes <INPUT type=radio value=N name=A1> No </TD></TR> <TR class=bgwhitetext><TD class=bgwhitetext width="70%">Do you like dogs ? </TD><TD><INPUT type=radio value=Y name=AC> Yes <INPUT type=radio value=N name=AC> No </TD></TR> <INPUT onclick="return validateinput(document.forms[0]);" tabIndex=3 type=image alt=CONTINUE src="webcert_filing.asp_files/button_continue.gif" align=right border=0 name=CONTINUE> </div> These questions are not a part of a form so I haven't been able to use _IEFormElementRadioSelect. Questions A1 and A2 will be answered as Yes so I am able to use the following for these 2 : <div class='codetop'>CODE</div><div class='codemain' style='height:200px;overflow:auto'> $oElement1 =_IEGetObjByName ($oIE, "A1") _IEAction($oElement1, "click") $oElement2 =_IEGetObjByName ($oIE, "A2") ;Need to answer No to A3 ;Need to answer No to AC _IEAction($oElement2, "click") $oElement5 =_IEGetObjByName ($oIE, "CONTINUE") _IEAction($oElement5, "click") </div> I have been struggling to find a way to click No for the other two questions. Edited December 18, 2010 by vyper0
weaponx Posted April 29, 2009 Posted April 29, 2009 Are you sure it's not a form? This little snippet says otherwise: onclick="return validateinput(document.forms[0]);"
vyper0 Posted April 30, 2009 Author Posted April 30, 2009 So I've tried a number of ways to click the No radio button on my webpage but I cannot figure out how to reference the radio button. I looked through the HTML of the page (which is in my post above) and I don't think the radio buttons are on a form and if it I cannot find the form name/ID.
DaleHohm Posted April 30, 2009 Posted April 30, 2009 make certain you are using something like DebugBar to look at the source. It is very likely some of it is being created dynamically and View Source will not show it to you. 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
vyper0 Posted April 30, 2009 Author Posted April 30, 2009 (edited) I do use the DebugBar. That's how I was able to get past the first two webpages. The first page is a login and the second I need to click a link to get to the questions that I am having trouble with. The first two pages I was able to get the form name. I'm pretty sure that the radio buttons on the third page are not part of a form and that's where I'm stuck. Here is the code I'm using for the first two pages that I need to navigate through. <div class='codetop'>CODE</div><div class='codemain' style='height:200px;overflow:auto'> #include <IE.au3> $oIE =_IECreate("http://google.com") ; waits for page to load before proceeding...i think _IELoadWait ($oIE) ; get pointers to the login form and username, password and signin fields $o_form = _IEFormGetObjByName($oIE,"form1") $o_login = _IEFormElementGetObjByName($o_form,"USER_ID") $o_password = _IEFormElementGetObjByName($o_form,"USER_PASSWORD") $o_signin = _IEFormElementGetObjByName($o_form,"LOGIN") ;fill out form _IEFormElementSetValue ($o_login, "$$$ID$$$") _IEFormElementSetValue ($o_password, "$$$PASS$$$") ;click login button ;_IEAction ($o_signin, "click") _IEFormImageClick ($o_form, "Login", "alt") _IELoadWait ($oIE) ;clicks link on second page to enter webcert _IELinkClickByText ($oIE, "Identifiable text to click on") _IELoadWait ($oIE) ;clicks continue on webform welcome page _IEFormImageClick ($oIE, "CONTINUE", "alt")</div> Here is what I'm working on now to get through the third page. As you can see by the commented out lines, I have tried several ways... <div class='codetop'>CODE</div><div class='codemain' style='height:200px;overflow:auto'> #include <IE.au3> $oIE =_IECreate("D:\Desktop\testpages\webform.asp.htm") ;_IELoadWait ($oIE) $oForms = _IEFormGetCollection ($oIE, 0) ; $oForm = _IEGetObjByName ($oIE, "AC") ; ;$oForm = _IEFormGetCollection ($oIE, 0) _IEFormElementRadioSelect ($oForm, "AC", 1) MsgBox(0, "Forms Info", "There are " & @extended & " forms on this page") For $oForm In $oForms MsgBox(0, "Form Info", $oForm.name) Next $oElement1 =_IEGetObjByName ($oIE, "A1") _IEAction($oElement1, "click") $oElement2 =_IEGetObjByName ($oIE, "A2") _IEAction($oElement2, "click") ; $oElement3 =_IEGetObjByName ($oIE, "A3") ; this doesnt work because Yes is selected and I need to choose No. ; _IEAction($oElement3, "click") ; $oElement4 =_IEGetObjByName ($oIE, "AC") ; this doesnt work because Yes is selected and I need to choose No. ; _IEAction($oElement4, "click") ; $oElement5 =_IEGetObjByName ($oIE, "CONTINUE"); this does work but I cannot choose continue until I complete all questions. ; _IEAction($oElement5, "click")</div> Edited December 18, 2010 by vyper0
vyper0 Posted April 30, 2009 Author Posted April 30, 2009 (edited) I used the following (along with Debug bar) to find all of the forms on the page. <div class='codetop'>CODE</div><div class='codemain' style='height:200px;overflow:auto'>#include <IE.au3> $oIE = _IECreate ("D:\Desktop\testpages\webform.asp.htm") $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</div> and the is only one form and this is all that the form consists of... <div class='codetop'>CODE</div><div class='codemain' style='height:200px;overflow:auto'><FORM method=post name=wb.asp autocomplete="off"></FORM></div> Edited December 18, 2010 by vyper0
vyper0 Posted May 1, 2009 Author Posted May 1, 2009 (edited) Is there a way to get _IEAction("click") to chose the no option for my radio button when the source HTML looks like this? So far I can only get it to choose Yes. <TR class=bgwhitetext><TD class=bgwhitetext width="70%">Do you like dogs ? </TD><TD><INPUT type=radio value=Y name=AC> Yes <INPUT type=radio value=N name=AC> No </TD></TR> Edited December 18, 2010 by vyper0
DaleHohm Posted May 1, 2009 Posted May 1, 2009 $oYes = _IEGetObjByName($oIE, "AC", 0) $oNo = _IEGetObjByName($oIE, "AC", 1) $oNo.checked = True or $oYes.checked = True 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
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