TAHAIC has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am trying to find way to wait until the the win32 system default browser has loaed the requested page so that further automated scrippting can occur...mainly keystrokes in my case. I am trying to eliminate the need for dedicated hard sleep times in order to minimise the time required. I have been considering the statusbar events etc. but I am really looking for something that will work with whatever the default browser is IE, Firefox, Moz etc.

Will the NavigateComplete2 event work for example?...or will it only work with IE?

Any input would be appriciated!

TAHAIC

  • Comment on Win32:: How to tell when Default browser url has loaded

Replies are listed 'Best First'.
Re: Win32:: How to tell when Default browser url has loaded
by wfsp (Abbot) on Dec 12, 2008 at 16:34 UTC
    The very wonderful Win32::GuiTest has a WaitWindow method which takes a regex for the window title as an argument. It can certainly help with the keystrokes.
Re: Win32:: How to tell when Default browser url has loaded
by MidLifeXis (Monsignor) on Dec 12, 2008 at 16:25 UTC

    See Selenium. It sounds like this might have some of the code that you want, if not a complete solution.

    --MidLifeXis

Re: Win32:: How to tell when Default browser url has loaded
by imrags (Monk) on Dec 12, 2008 at 16:30 UTC
    Try this:
    Call the function while the page is being loaded
    sub Wait_For_Complete_Load { while($agent->{agent}->Document->readyState !~ /complete/i) { sleep(1); } }
    Raghu
    this works with IE
Re: Win32:: How to tell when Default browser url has loaded
by imrags (Monk) on Dec 12, 2008 at 16:38 UTC
    Yes, Try Win32::IEAutomation & Win32::GUITest
    Raghu
      imrags

      Could you explain that code for me I am not quite sure how it works. Which modules does it require.

      I am already using Win32::GuiTest for the keystrokes, this part is working fine.I am also using the WaitWindow function for checking a standard application window but it dosen't seam to work with the browser window, or I'm doing something wrong. Also I noticed that the title of the browser appears before the page has finished loading.

      I have tried WaitWindowLike for a child process of a normal application window but I don't seam to be able to get it to work, some help with that would also be appriated.

      I was thinking that I could use Win32::API to import a win32dll function that would do the job, but I'm not sure which one to use...considering I don't want to force the user to use IE.

        Ok...Sorry to disappoint you but this function was written for IE and the object $agent was for a Win32::IEAutomation object.
        This is for a webpage which has javascript and if it takes some time to load (for e.g. if you are searching for something on a website and it says "Searching ... or Please Wait while we search")...
        In this case the page is not completely loaded, hence you would have to wait for the page to complete.
        That's when this code will come into picutre...
        I'm not sure but I think You can replace the $agent for any Win32 Module you are using to load the page...
        Raghu