sumit Posted August 14, 2007 Share Posted August 14, 2007 Im trying to click the browse button at the site http:skurfit.com.. CODE#include<IE.au3> $oIE = _IECreate("http://skurfit.com",0,1,0,0) $Btn = _IEGetObjByName($oIE, "browse") _IEAction($Btn, "click") But its not working , Please tell me whats wrong Im getting this error C:\Program Files\AutoIt3\beta\Include\IE.au3 (2605) : ==> The requested action with this object has failed.: If IsObj($o_object.document.GetElementsByName ($s_Id).item ($i_index)) Then If IsObj($o_object.document^ ERROR Link to comment Share on other sites More sharing options...
Generator Posted August 14, 2007 Share Posted August 14, 2007 $oIE = _IECreate("http://skurfit.com",0,1,1,0) Wait before the page has loaded completely? Link to comment Share on other sites More sharing options...
sumit Posted August 14, 2007 Author Share Posted August 14, 2007 $oIE = _IECreate("http://skurfit.com",0,1,1,0)Wait before the page has loaded completely?This page has so many images etc. that it takes a lot of time for them to download all.... however this button is visible almost immediately .... so what should i do ? Link to comment Share on other sites More sharing options...
Reaper HGN Posted August 14, 2007 Share Posted August 14, 2007 $oIE = _IECreate("http://skurfit.com",0,1,1,0) Wait before the page has loaded completely? I dont know the IE include very well (whether it has some form of "wait till the page loads") but I will say that waiting works. You need to make sure you wait before _IEGetObjByName so the page can actually load. This worked for me. #include<IE.au3> $oIE = _IECreate("http://skurfit.com",0,1,0,0) sleep(5000) $Btn = _IEGetObjByName($oIE, "browse") _IEAction($Btn, "click") look for something else rather than the sleep, but this tested the concept. Link to comment Share on other sites More sharing options...
Generator Posted August 14, 2007 Share Posted August 14, 2007 Then you should do this... #include<IE.au3> _IEErrorHandleRegister() _IELoadWaitTimeout(5000) $oIE = _IECreate("http://skurfit.com",0,1,1) $Btn = _IEGetObjByName($oIE, "browse") _IEAction($Btn, "click") Link to comment Share on other sites More sharing options...
DaleHohm Posted August 14, 2007 Share Posted August 14, 2007 (edited) Another things to consider... DOM elements have a readyState (as well as overall Documents and the browser). readyState's you can look for would be 3 (can also be "interactive) or 4 (can also be "complete"). Once the button has a readyState value of 3 or 4 you can interact with it. You can monitor the readyState with _IEPropertyGet with the "readyState" prameter. Note that you may need to add _IEErrorHandlerRegister() to prevent COM errors you can get from trying to examine a not-yet-existing element from being fatal. Dale Edit: typo Edited August 14, 2007 by DaleHohm 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...
sumit Posted August 14, 2007 Author Share Posted August 14, 2007 I dont know the IE include very well (whether it has some form of "wait till the page loads") but I will say that waiting works. You need to make sure you wait before _IEGetObjByName so the page can actually load. This worked for me. #include<IE.au3> $oIE = _IECreate("http://skurfit.com",0,1,0,0) sleep(5000) $Btn = _IEGetObjByName($oIE, "browse") _IEAction($Btn, "click") look for something else rather than the sleep, but this tested the concept. Thanks a lot buddy mine works with sleep(8000) can you also tell me how to replace "www.myspace.com" as the input value to "www.gmail.com" Link to comment Share on other sites More sharing options...
sumit Posted August 14, 2007 Author Share Posted August 14, 2007 Then you should do this... #include<IE.au3> _IEErrorHandleRegister() _IELoadWaitTimeout(5000) $oIE = _IECreate("http://skurfit.com",0,1,1) $Btn = _IEGetObjByName($oIE, "browse") _IEAction($Btn, "click") I get this error ERROR: _IEErrorHandleRegister(): undefined function. Link to comment Share on other sites More sharing options...
Generator Posted August 14, 2007 Share Posted August 14, 2007 _IEErrorHandlerRegister()... I didn't really look at help file when i post. Link to comment Share on other sites More sharing options...
sumit Posted August 14, 2007 Author Share Posted August 14, 2007 _IEErrorHandlerRegister()...I didn't really look at help file when i post.Thanks a lot even I didnt look at the help file before posting the error... lol.Please help me also to enter value in the input element for browsing ... i want to use $oForm = _IEFormGetObjByName($oIE, "")$oQuery = _IEFormElementGetObjByName($oForm, "")_IEFormElementSetValue($oQuery, "www.gmail.com")but unfortunately i cannot see the name of the form on the html source of the page Link to comment Share on other sites More sharing options...
Generator Posted August 14, 2007 Share Posted August 14, 2007 Here... #include<IE.au3> _IEErrorHandlerRegister() _IELoadWaitTimeout(5000) $oIE = _IECreate("http://skurfit.com",0,1,1) $oForm=_IEFormGetCollection($oIE,0) $oQuery=_IEFormElementGetCollection($oForm,0) _IEFormElementSetValue($oQuery, "www.gmail.com") MsgBox(64,"","Going to click") $Btn = _IEGetObjByName($oIE, "browse") _IEAction($Btn, "click") _IELoadWait($oIE,5000,5000) Link to comment Share on other sites More sharing options...
sumit Posted August 14, 2007 Author Share Posted August 14, 2007 Here... #include<IE.au3> _IEErrorHandlerRegister() _IELoadWaitTimeout(5000) $oIE = _IECreate("http://skurfit.com",0,1,1) $oForm=_IEFormGetCollection($oIE,0) $oQuery=_IEFormElementGetCollection($oForm,0) _IEFormElementSetValue($oQuery, "www.gmail.com") MsgBox(64,"","Going to click") $Btn = _IEGetObjByName($oIE, "browse") _IEAction($Btn, "click") _IELoadWait($oIE,5000,5000) Thanks a lot buddy .... thats so nice Link to comment Share on other sites More sharing options...
DaleHohm Posted August 14, 2007 Share Posted August 14, 2007 Actually, this would probably be the fastest, most reliable solution: #include<IE.au3> _IEErrorHandlerRegister() $oIE = _IECreate("http://skurfit.com",0,1,0,0) $Btn = 0 While Not IsObj($Btn) $Btn = _IEGetObjByName($oIE, "browse") Sleep(100) WEnd _IEAction($Btn, "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...
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