sgn209 Posted February 8, 2014 Posted February 8, 2014 (edited) Hi everybody in AutoIT forum, have a good day. I want to write a program can automatic fill IE form but I have some problem when get form name in this code: </script> <font color="#990000"><div id="ajax-address-error"></div></font><table class="enterAddressFormTable"><div id="enterAddressFormDiv"> <tr><td class="enterAddressFieldLabel" style="vertical-align:middle;"><span><label for="enterAddressFullName"><b>Full Name: </b></label></span></td><td><span> <input type="text" name="enterAddressFullName" id="enterAddressFullName" class="enterAddressFormField" size="50" maxlength=50 /></span> </td></tr><tr><td class="enterAddressFieldLabel" style="vertical-align:middle;"><span><label for="enterAddressAddressLine1"><b>Address Line1: </b></label></span></td><td><span> <input type="text" name="enterAddressAddressLine1" id="enterAddressAddressLine1" class="enterAddressFormField" size="50" maxlength=60 /></span> <br /><span class="tiny">Street address, P.O. box, company name, c/o</span></td></tr><tr><td class="enterAddressFieldLabel" style="vertical-align:middle;"><span><label for="enterAddressAddressLine2"><b>Address Line2: </b></label></span></td><td><span> <input type="text" name="enterAddressAddressLine2" id="enterAddressAddressLine2" class="enterAddressFormField" size="50" maxlength=60 /></span> <br /><span class="tiny">Apartment, suite, unit, building, floor, etc.</span></td></tr><tr><td class="enterAddressFieldLabel" style="vertical-align:middle;"><span><label for="enterAddressCity"><b>City: </b></label></span></td><td><span> <input type="text" name="enterAddressCity" id="enterAddressCity" class="enterAddressFormField" size="25" maxlength=50 /></span> </td></tr><tr><td class="enterAddressFieldLabel" style="vertical-align:middle;"><span><label for="enterAddressStateOrRegion"><b>State/Province/Region: </b></label></span></td><td><span> <input type="text" name="enterAddressStateOrRegion" id="enterAddressStateOrRegion" class="enterAddressFormField" size="15" maxlength=50 /></span> </td></tr><tr><td class="enterAddressFieldLabel" style="vertical-align:middle;"><span><label for="enterAddressPostalCode"><b>ZIP: </b></label></span></td><td><span> <input type="text" name="enterAddressPostalCode" id="enterAddressPostalCode" class="enterAddressFormField" size="20" maxlength=20 /></span> </td></tr><tr><td class="enterAddressFieldLabel" style="vertical-align:middle;"><span><label for="enterAddressCountryCode"><b>Country: </b></label></span></td><td><span> This code from AMAZON with link: https://www.amazon.com/gp/css/account/address/view.html?ie=UTF8&ref_=ya_add_address&viewID=newAddress Here is code i always use to fill IE form name: $oForm = _IEFormGetObjByName($OIE, $FORMNAME) $OQUERY = _IEFormElementGetObjByName($oForm, "enterAddressFullName") _IEFormElementSetValue($OQUERY, $2FName) $OQUERY = _IEFormElementGetObjByName($oForm, "enterAddressAddressLine1") _IEFormElementSetValue($OQUERY, $2Add1) $OQUERY = _IEFormElementGetObjByName($oForm, "enterAddressAddressLine2") _IEFormElementSetValue($OQUERY, $2Add2) $OQUERY = _IEFormElementGetObjByName($oForm, "enterAddressCity") _IEFormElementSetValue($OQUERY, $2City) I want to know $FORMNAME in this case or any other ways else I can do for fill the form ? Thanks Edited February 8, 2014 by sgn209
Danp2 Posted February 8, 2014 Posted February 8, 2014 It appears that the form doesn't have an assigned name. You can use _IEFormGetCollection to get a collection of forms and then loop through the collection until you find the desired form. Latest Webdriver UDF Release Webdriver Wiki FAQs
sgn209 Posted February 8, 2014 Author Posted February 8, 2014 It appears that the form doesn't have an assigned name. You can use _IEFormGetCollection to get a collection of forms and then loop through the collection until you find the desired form. how to do it ? Can you show me an example ? Thanks
Solution mikell Posted February 8, 2014 Solution Posted February 8, 2014 You can also loop through the inputs $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput In $oInputs If $oInput.name == "enterAddressFullName" Then $oInput.innertext = $2FName If $oInput.name == "enterAddressAddressLine1" Then $oInput.innertext = $2Add1 ; etc Next sgn209 1
Danp2 Posted February 8, 2014 Posted February 8, 2014 how to do it ? Can you show me an example ? Thanks See the example in the help file. Latest Webdriver UDF Release Webdriver Wiki FAQs
sgn209 Posted February 9, 2014 Author Posted February 9, 2014 You can also loop through the inputs $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput In $oInputs If $oInput.name == "enterAddressFullName" Then $oInput.innertext = $2FName If $oInput.name == "enterAddressAddressLine1" Then $oInput.innertext = $2Add1 ; etc Next Great ! Its work perfectly ! Thanks
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