Gianni Posted June 15, 2013 Share Posted June 15, 2013 (edited) Hello I'm trying to automate an web application that is build with frames and a lot of javascipt, the first page is a login page with 2 input box (username and password) and a login button no problems to automate input of credentials and click button on this page #include <ie.au3> $oIE = _IECreate ("https://mypage:7493/idem/suite/login.do") $oFrame = _IEFrameGetCollection($oIE, 0) ; first frame (frame 0) $oForm = _IEFormGetObjByName ($oFrame, "basicLogonForm"); this form is inside the frame $oQuery1 = _IEFormElementGetObjByName ($oForm, "username") ; first field inside the form $oQuery2 = _IEFormElementGetObjByName ($oForm, "userpassword") ; second field inside the form $uname="MyUsername" $pwd="MyPassword" _IEFormElementSetValue ($oQuery1,$uname) ; input username _IEFormElementSetValue ($oQuery2,$pwd) ; input password $oButton=_IEGetObjById($oFrame,"button") ; reference to button _IEAction ($oButton, "click") ; click on button _IELoadWait($oIE) ; <=== here, the script goes on without waiting ; and following statements give error ; Sleep ( 10000 ) ; if I force waiting, the script give no error ; because the new page has time to load itself Local $oFrame = _IEFrameGetObjByName($oIE, "main-frame") ; new frame in the new page $oForm = _IEFormGetObjByName ($oFrame, "SimpleSearchfrm"); new form in new page $oQuery1 = _IEFormElementGetObjByName ($oForm, "simplesearchquery") _IEFormElementSetValue ($oQuery1,"nametosearch") .... etc .... but after clicking the button, the second page that is displayed, is loaded by some javascript function (i guess something like top.location.replace("login.do") the problem (in line 30) is that i am not able to wait till the new page is loaded, and so the script goes on while the new page is not ready, causing errors. i tryed to use the _IELoadWait($oIE) function but with no success, maybe it is not the right function in this context. I would need some suggestions thank you Edited June 16, 2013 by Pincopanco Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
water Posted June 15, 2013 Share Posted June 15, 2013 Did you read the remarks in the help file for _IELoadWait? "... prevent _IELoadWait from guaranteeing that a page is fully loaded ... use Sleep command, examining browser status bar text and other methods ..." Another method would be to wait until a specific object exists. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
DW1 Posted June 15, 2013 Share Posted June 15, 2013 (edited) You will need to do your own check to see when the page is done loading. For example, if the issue is "simplesearchquery" doesn't exist yet, write a loop that checks for its existence every 200ms. "simplesearchquery" is of course just an example, and you will need to find out exactly what you are waiting for the javascript to create. Javascript/ajax will commonly run asynchronously, so there is no way for the browser to know when it is finished and report it to you. EDIT: ninja'd by water Edited June 15, 2013 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
water Posted June 15, 2013 Share Posted June 15, 2013 just faster fingers My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Gianni Posted June 15, 2013 Author Share Posted June 15, 2013 ok, thanks for answers well... how to wait until a specific object exists on a new page? for example a form Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
water Posted June 15, 2013 Share Posted June 15, 2013 Use _IEGetObjById in a loop while @error = 7 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Gianni Posted June 15, 2013 Author Share Posted June 15, 2013 well, many thanks water & danwilli for showing me the direction, i will try in that way bye Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Gianni Posted June 16, 2013 Author Share Posted June 16, 2013 ... I can not find the solutionI try in this way to wait until an object exists in the browser Do Local $oFrame = _IEFrameGetObjByName($oIE, "main-frame") ConsoleWrite("error: " & @error & @CRLF) Until @error but I get this error C:Program Files (x86)AutoIt3Includeie.au3 (813) : ==> The requested action with this object has failed.: If $oFrame.name = $s_Name Then Return SetError($_IEStatus_Success, 0, $oTemp.frames($s_Name)) If $oFrame.name = $s_Name Then Return SetError($_IEStatus_Success, 0, $oTemp.frames($s_Name)^ ERROR ->11:42:06 AutoIT3.exe ended.rc:1 >Exit code: 1 Time: 3.011and the script exits any help is welcome Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Danp2 Posted June 16, 2013 Share Posted June 16, 2013 It's possible that this error is due to the page reloading during the call to the _IEFrame* function. Did you try it using _IEGetObjById as suggested by water? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
water Posted June 16, 2013 Share Posted June 16, 2013 To prevent your script from crashing call _IEErrorHandlerRegister (with the default or a custom error handler). Or run your script with Beta version 3.3.9.x of AutoIt. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Gianni Posted June 16, 2013 Author Share Posted June 16, 2013 .. still NOT out of troubles .. I modified my script like this: _IEErrorHandlerRegister () Do Sleep(500) Local $oFrame = _IEFrameGetObjByName($oIE, "main-frame") ; Until not @error ; DO NOT WORK ; Until $oFrame <> 0 ; DO NOT WORK Until ???until_WHAT??? but I do not know how to exit from the Do / Until loop which condition do I have to check in the Until ????? what is the condition that tells me that the object has been created? Until not @error do not works Until $oFrame <> 0 do not works please, any help is welcome .... Thank You Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Solution water Posted June 16, 2013 Solution Share Posted June 16, 2013 Try "Until IsObj($oFrame)" because _IEFrameGetObjByName returns an object. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Gianni Posted June 16, 2013 Author Share Posted June 16, 2013 Thanks water Until IsObj($oFrame) it worked but I was not right in my previous post; Until $oFrame <> 0 also works, I was confused by successive errors that came from other objects that still was not build. ( forms, and FormElements) that I referenced too early. so I realized that I have to use Do / Until loops for any alement of the web page, or, much better, at least for the last one element of the web page that will be build. ..... now i feel better ..... Thanks again water for your support. Bye Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
water Posted June 16, 2013 Share Posted June 16, 2013 so I realized that I have to use Do / Until loops for any alement of the web page, or, much better, at least for the last one element of the web page that will be build.That's what I would do too. Wait until the last element on the page exists.Or check the status line. Maybe a "Ready" or something appears or a "Loading" vanishes when the page has finished loading. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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