marsol Posted December 31, 2006 Share Posted December 31, 2006 I'm receiving this error when I use the _IEFormElementSetValue more than once for the same field."IE.au3 Error from function _IEFormElementSetValue, $_IEStatus_InvalidObjectType"The bulk of the original script was kindly provided by SandyD in this post http://www.autoitscript.com/forum/index.php?showtopic=38605My problem arises when I run a loop trying multiple cabin numbers. Here's a somewhat simplified version of the script that demonstrates the same problem.CODE#include <IE.au3>HotKeySet("^!x", "MyExit")$oIE = _IECreate ("http://www.carnival.com/BonVoyage/AddToCart.aspx?pid=745")_IELoadWait ($oIE); Create a variable to store the form$oForm = _IEFormGetObjByName ($oIE, "addToCartSearchResults")$BookNumField = _IEFormElementGetObjByName ($oForm, "AddToCart1:bookingNumber")_IEFormElementSetValue ($BookNumField, "6x14v1")$CabNumField= _IEFormElementGetObjByName ($oForm, "AddToCart1:cabinNumber")$cabnum=1000While 1 _IEFormElementSetValue ($CabNumField, $cabnum) ; Submit the form _IEFormImageClick ($oIE, "AddToCart1:btnSubmit", "name") ; wait until webpage has loaded _IELoadWait ($oIE) ; get html from page and check if 'Invalid Booking and/or Cabin Number' text is found $sHTML = _IEDocReadHTML ($oIE) If StringInStr($sHTML,"Specify Delivery") Then MsgBox(0,'','Found') Else MsgBox(0,'','NOT Found') EndIf $cabnum=$cabnum+1WendFileClose($file)Func MyExit() msgbox(1,"lll","exiting") Exit EndFunc ; Finished!I've tried explicitly declaring the variables but that didn't seem to help. What am I doing wrong?Thanks,Mark Link to comment Share on other sites More sharing options...
marsol Posted December 31, 2006 Author Share Posted December 31, 2006 Okay, so I guess this is what I wasn't doing right. I need to have these two statements within the loop for it to work. $oForm = _IEFormGetObjByName ($oIE, "addToCartSearchResults") $CabNumField= _IEFormElementGetObjByName ($oForm, "AddToCart1:cabinNumber") With my admittedly limited understanding I thought $oForm and $CabNumField were object variables and that these were persistent. Obviously some part of my understanding is wrong. Mark Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted December 31, 2006 Share Posted December 31, 2006 put "" around the 1000 for $cabnum Link to comment Share on other sites More sharing options...
DaleHohm Posted December 31, 2006 Share Posted December 31, 2006 Okay, so I guess this is what I wasn't doing right. I need to have these two statements within the loop for it to work.$oForm = _IEFormGetObjByName ($oIE, "addToCartSearchResults")$CabNumField= _IEFormElementGetObjByName ($oForm, "AddToCart1:cabinNumber")With my admittedly limited understanding I thought $oForm and $CabNumField were object variables and that these were persistent. Obviously some part of my understanding is wrong.MarkCorrect. When the page reloads the previous document is destroyed and a new one created. Thus the object references to the elements on the page need to be re-established because the previous objects are no longer valid.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...
marsol Posted December 31, 2006 Author Share Posted December 31, 2006 Thanks Dale, That makes sense, of course. I'm amazed at the power of autoitscript and it's extensions. Mark 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