Sign in to follow this  
Followers 0
dwaynek

how do i detect when mozilla firefox is done loading a page?

20 posts in this topic

i'd like to write a script that launches firefox and waits until it's done loading a particular website before proceeding on to the next line of code. is there a way to do this?

Share this post


Link to post
Share on other sites



i'd like to write a script that launches firefox and waits until it's done loading a particular website before proceeding on to the next line of code. is there a way to do this?

Not many ways I know of other than checking pixel locations, and with people having different themes etc... I don't think that's a viable way of doing it IMHO.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

This is a guess / test / something i just came up with... is there anyway you could check the sourcecode in FF. Kinda When the two <html> and </html> is there, the site is ready to be handled or is it a bad idea


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

This is a guess / test / something i just came up with... is there anyway you could check the sourcecode in FF. Kinda When the two <html> and </html> is there, the site is ready to be handled or is it a bad idea

how would you check the source... of the currently loaded page in firefox?

Edit:

Silently and without mouseclicks that is.

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

That part was a question from my side ;) I dont know if theres anyway of seeing that :evil: But if there is, that might be a way to do it :lmao:


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

it will not be fast

it will not be portable to other users

it may not work for all pages

; locate the path to the file named "sessionstore.js"
; C:\Documents and Settings\...username...
; ...\Application Data\Mozilla...
; ...\Firefox\Profiles\...something random...
; ...\sessionstore.js

;add the full path here
$path2sessionstore = ""

$start = FileGetTime($path2sessionstore, 0, 1)

$app = "C:\Program Files\Mozilla Firefox\firefox.exe"
$URL = "http://www.autoitscript.com/forum/index.php?showtopic=36566"
Run($app & " " & $URL)

Do
    $end = FileGetTime($path2sessionstore, 0, 1)
    ToolTip($end)
    Sleep(100)
Until $start <> $end

ToolTip("")

MsgBox(0, "", "Page loaded")

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

That is not working for me. It just display page load before the page is actually loaded. I guess this means that it displays the msg when the command is run successfully not the page is loaded sucessfully. I am too looking for the same solution.

I want to know

Firefox compatiblity (of IE.au3)

I want to know that how can i create a simple process for my FTP UPLOAD VIA HTML.

Loop
1)Open a page
2)enter information in 4 text fields
3)Wait till the files get uploaded (detect the progress)(next page will load) 
4)again click the verification button in the next page
goto loop

Right now i am using Autoit but sometime it gets wrong in the 3 step it doesn't detect the load which render incomplete file upload. (No file get uploaded)

I want this to work in firefox because it saves a hell lot of bandwidth and damn faster than IE

Firefox can disable image views

It has a great Greasemonkey plugin (Which i use the most)

But i really can't understand how to tell the autoit program to look for the page is completely loaded.

Share this post


Link to post
Share on other sites

......create a simple process for my FTP UPLOAD VIA HTML....

It is not going to be such a simple process using Firefox.

Could you post a URL to the site you are uploading files to? ...or at least post a URL to some similar site that forum members can work with.

You could always script with IE and surf with Firefox. Also, if this script is just for you, try using AutoIt's Pixel.... functions to "see" whatever you see as a human to know when the upload has completed within Firefox.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

I can't share the link coz it is under private registration. Hope u understand.

It is a simple asp page and first it displays browse button and a Text box which get filled with path of the file.

and a upload button. When i select the file cia browse or manually typing it is uploaded after i press the upload button.

After click the upload button the file get submitted to the server and here on the screen it shows the confirmation page where it says junk like "Your file has been uploaded" than after that when i directly go to the upload page by typing the url (there is no link on the confirm page) it doesn't accept untill i visit the index page.

Now the program i made is simple it searches for browser button Pixel Color than it enter the file name (it is renamed to number so that incrementation is possible). And submits the file. Goes to address bar type addres of index hit enter than after that type the enter of upload page hit enter and again the next file.... Looping

Now my problem is that i want a convenient way coz when i do this method some time the file takes long to upload (ihave slow connection) so the Upload screen hang on the screen for about min by which when the next file process start the program doesn't know that the first file is uploaded or not and it retypes the previous entered path.

Kindly tell me faster more reliable way. Thank You very much.

Share this post


Link to post
Share on other sites

That is not working for me. It just display page load before the page is actually loaded. I guess this means that it displays the msg when the command is run successfully not the page is loaded sucessfully. I am too looking for the same solution...

Does the little script that I posted work for you when you test using the AutoIt forum page that I used in the code? Not testing with your FTP site, test with the code that I posted... just to let me know that it works for others. Close all browsers and clear the temp file cache - then run that little test script. It should work. The MsgBox should only show after the entire page has loaded.

I can't share the link coz it is under private registration. Hope u understand...

Yes, I understand, but I was hoping that the site was something that others could register (for free) and help you test some code. Or maybe you know of a public/free site that has the same upload steps? Something that we could work with.

...Now the program i made is simple it searches for browser button Pixel Color.........

It would probably be "simpler" to script it via IE.au3.

...Kindly tell me faster more reliable way. Thank You very much.

I do not know of another way. Maybe others can write code for Firefox based on your description of the task, but I cannot. If you figure it out, post a generic version of your script as I'm sure others would be interested.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thank you very much at least for the support ;)

Share this post


Link to post
Share on other sites

Can't you search for this text"

Posted Image

It's swedish, but it should say "Done"

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Yep, you should be able to check the statusbar text to tell when it's loaded or not.

Posted Image

StatusbarGetText ( "title" [, "text" [, part]] )
Edited by Googler24022

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Thank you very much at least for the support ;)

Here is a new idea.

1.) run "netstat -n -p tcp" and parse the output

2.) Start down-/upload via Firefox

3.) run "netstat -n -p tcp" again. The "delta" will be the connections that firefox opened. They will be closed when firefox is ready to down-/upload the file. You can nail down the entry is you know the URL that firefox is accessing. Then you can get the IP address of the host and find the correct connection within the netstat data.

4.) run "netstat -n -p tcp" in a loop and check if the connection is still "ESTABLISHED". If so, Firefox is still downloading. If the connection is gone, chances are very high, that firefox is ready.

EDIT: 5.) If you add "-b" you will also see the PID and the process name, at least on WinXP.

EDIT: 6.) It may take some time until the "ESTABLISHED" entry gets removed, so this might only work well for longer down-/uploads as the wait time is short in relation to the up/download time .....

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

i'd like to write a script that launches firefox and waits until it's done loading a particular website before proceeding on to the next line of code. is there a way to do this?

I use the following code:

;This function waits until the hourglass goes away
func WaitUntilDone($max_wait = 120000)
    local $counter = 0
    while(mousegetcursor() = 1)
        $counter = $counter + $iShortDelay
        sleep($iShortDelay)     
        if($counter > $max_wait) Then
            exit_program("Stuck in wait until done loop, exited after " & string($counter) & "ms, mousegetcursor is: " & string(mousegetcursor()))
        EndIf
    WEnd
    sleep($iShortDelay / 4)
endfunc

Basically The mousegetcursor() is the key line... before running this function, I move the mouse to a position that I know does not have anything that will interfere with the cursor state. Of course I use this in a controlled environment... All of the variables and functions should be self explanatory...

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Can't you search for this text"

Posted Image

It's swedish, but it should say "Done"

You can't get that text, but you can use PixelChecksum() to calculate a checksum for that area which it show "ready" (or whatever it's called in your language) and then, when firefox is loading the page, constantly checking the same area with PixelChecksum until it shows the same value....

Anyway, I think the method fsquirrelgpr has posted is by far the best way to check if the download has finished.

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

What about pixel search the whole screen for pixels with ressembles "Done"?

Share this post


Link to post
Share on other sites

I don't have a solution...just wanted to throw an idea out:

What is the last thing Firefox does when it finishes loading a page? Is it something we can detect and wait for it?

Or, what is the last line in the web page process? May be detect the </HTML> script command?

Share this post


Link to post
Share on other sites

I use this:

Func doneload()
    TrayTip("Script is running!", "Press x key to exit program", 60)
    sleep(500)
    $cursor=MouseGetCursor()
    While $cursor <> 2
        $cursor=MouseGetCursor()
        sleep(1000)
    WEnd
    If WinExists("Problem loading page") = 1 Then
        Send("{F5}")
        doneload()
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

@psgame_freak,

A function should never call itself.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0