Waiting for a Web page to load
Keywords: load web page
Question:
I am launching an application that brings up a modal form. I wish to send keystrokes to this form but WinBatch won't wait for the form to load before issuing the SendKeysTo command. I've tried all of the examples the help recommended to no avail. Is there any way I can do this without using a pre-set time delay?Answer:
In the Control Manager extender there is a cGetSBText function that can read the status bar at the foot of Netscape and MSIE browsers.So it can look for the DONE message when the browser is finished loading. Works great.
Question:
Is there a way to force Winbatch to wait for the entire web page to load before proceeding? I tried WinWaitExist but the Window name loads before all the graphics do.I am trying to time Netscape as part of Performance monitoring of an application that is migrating to a web based platform. I have looked at the WinBatch Internet extender, however that does not give me the same result as Netscape. I have also tried to key on the IsMenuEnabled function, however it only works if the application supports it. Any other ideas would be helpful.
Answer:
Netscape seems particularly hard to work with.Sometimes its better to step back and look at what you are trying to accomplish. If you are trying to move information to files there are a couple of different ways to do it.
I'll start off recommending our Internet Extender which allows you to download web pages or images directly to files. No web browser needed.
- If you just need to grab web data, the Internet Extender can help.
- With IE4, there is a little "Done" at the lower-left corner of the screen. This word disappears as soon as you move the mouse over a link, etc. to change what is displayed to a URL. This works with HTTP.
However, if you are using HTTPS, that portion of the screen is locked, and we can't get to it.
Notice that the little globe stops turning when the page is finished loading, at which time a windows message is sent out and the window parameters are set to 0... unfortunately Winbatch has no way of intercepting a windows message, so we can't do anything with this information. If you can switch over to Netscape, you might have more luck detecting when the page is loaded, when using HTTPS.
- With Netscape 4.5, it says "Document: Done" when the page is complete. This is replaced by a URL if you move the mouse over a link but reappears after moving the mouse to a blank area of the screen.
- The cGetSBText funtion in the newer versions of the Control Manager extender should be able to detect this text. If you don't have that function, you can download an updated copy of the extender from the download area.
Here is a subroutine that seems to do the trick - this particular one works with IE4 and the "Done" at the bottom of the window. For NN4.5 change "Done" to "Document: Done". You WinBatch pros out there can probably clean up or make suggestions on improving my code, but this seems to work.
Make certain you set the hwnd varaible once at the top of the program using some lines similar to:
runzoom("C:\Program Files\Plus!\Microsoft Internet\IEXPLORE.EXE", "") timedelay(2) ie1=winidget("~Microsoft Internet Explorer") hwnd=dllhwnd(ie1) hwnd=cwndbyclass(hwnd, "msctls_statusbar32") timedelay(10)- ScreenShots... They are harder. Not a recommended route.
- Automate some operation... Netscape responds to OLE automation. Winbatch supports it with the ObjectOpen function. The documentation is on the Netscape site. There are a bunch of Netscape OLE operations available (see the BinaryOleType example).
- If you can find documentation on API calls, Winbatch can usually access then with the DllCall function.
- One of our users recommended the following:
One technique may be to place a line of Javascript at the end of the the HTML which in turn opens a dummy window with a title that you can wait for. I'm not sure if the images will have been loaded, or if you can use the onLoad event to perform a similar function (this technique is sucky, but bottom line - Winbatch can detect a new Window). In this example, we are inserting a JavaScipt applet to pop up a window saying "loaded" and Winbatch can see that.
Another Question on Determining if Page has Loaded:
Is there some way to winbatch know if the webpage loaded (done)? I have to see if the page is open and only after it is opened I have to send some keys to it to process the information and show to the user the answer of the page.Ex.: I have to open an webpage with any browser (Netscape or IExplorer). As soon as it opens I have to send to the page some infomation on certain fields. My question is: Is it possible to see if the browser have finished to read the page?
I tried use the window name, but when it starts to open, window name appears, but I don't know the necessary DELAY TO SEND THIS TEXT TO THE PAGE.
Answer:
It is quite tricky to watch a Browser and see when it is done. Several different strategies have been used, but none of them are particularly easy. If all you want to do is fill out a form and capture information - you may not need the Browser - the new WININET extender *might* be able to do it for you.Is the process supposed to be 100% automated, or does a real user have to examine the screen and make decisions?
If it's a real user, then they could press a key to continue.
If it is 100% automated, then with Winbatch and the (old) WinSock or the (new) WinInet extenders you can completely automate the operation without a Browser. Winbatch with the extenders can read and respond to web pages. If the HTML page that you're opening is one that you can edit yourself, then having WinBatch check to see if the page is loaded is a cinch. If the page isn't something that you can edit, though, well damn, good luck.
The best way to detect page loaded is to check whether the View|Stop option (I forgot what it is called in NN) is active or not. However, the newer IE4 interface (it is actually the new menu used in all newer office applications) is still beyond the Control Manager extender. We still have not cracked the MSIE buttonbar/menu.
Response from User:
The user has to see the page and after loaded, the winbatch script has to send some information and I can't edit the page.On Netscape I found a solution (I think) that I'm going to test. I open the browser with the page that I want and I check if the menu VIEW/PAGE SOURCE is enabled or not. If it's enabled, it has finished loading.
Now, on IExplorer I don't have any clue since the menu items are always enabled.
Article ID: W13359Filename: Wait for a Web Page to Load.txt