Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

how to wait a new web page opened by javascript is ready?

$
0
0

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

AutoIt         
  1. #include <ie.au3>
  2. $oIE = _IECreate ("https://mypage:7493/idem/suite/login.do")
  3.  
  4. $oFrame = _IEFrameGetCollection($oIE, 0) ; first frame (frame 0)
  5.  
  6. $oForm = _IEFormGetObjByName ($oFrame, "basicLogonForm"); this form is inside the frame
  7.  
  8. $oQuery1 = _IEFormElementGetObjByName ($oForm, "username") ; first field inside the form
  9. $oQuery2 = _IEFormElementGetObjByName ($oForm, "userpassword") ; second field inside the form
  10.  
  11. $uname="MyUsername"
  12. $pwd="MyPassword"
  13.  
  14. _IEFormElementSetValue ($oQuery1,$uname) ; input username
  15. _IEFormElementSetValue ($oQuery2,$pwd) ; input password
  16.  
  17. $oButton=_IEGetObjById($oFrame,"button") ; reference to button
  18.  
  19. _IEAction ($oButton, "click") ; click on button
  20.  
  21. _IELoadWait($oIE) ; <=== here, the script goes on without waiting
  22.                   ; and following statements give error
  23.  
  24. ; Sleep ( 10000 ) ; if I force waiting, the script give no error
  25.                   ; because the new page has time to load itself
  26.  
  27. Local $oFrame = _IEFrameGetObjByName($oIE, "main-frame") ; new frame in the new page
  28.  
  29. $oForm = _IEFormGetObjByName ($oFrame, "SimpleSearchfrm"); new form in new page
  30.  
  31. $oQuery1 = _IEFormElementGetObjByName ($oForm, "simplesearchquery")
  32.  
  33. _IEFormElementSetValue ($oQuery1,"nametosearch")
  34.  
  35. .... 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


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>