tags:

views:

83

answers:

3

Is there some module for Python that tells me when some page finish the loading, or something else on Firefox?

+4  A: 

There's selenium

Code example test_google.py:

from selenium import selenium

sel = selenium("localhost", 4444, "*firefox", "http://www.google.com/webhp")
sel.start()

sel.open("http://www.google.com/webhp")
sel.type("q", "hello world")
sel.click("btnG")
sel.wait_for_page_to_load(5000)
assert "hello world - Google Search" == sel.get_title()
sel.stop()
nosklo
but how do I use it with python ?
Shady
Is there a way to only open the google.com (at your example), without the other window, the log/test one, Remote control window ?
Shady
or maximize the google window and bring it to the front, letting the remote control window minimized or behind
Shady
+1  A: 

You can use the moz-repl plugin. It will instantiate a command prompt on a local port and you can then script it using the cmd module. This will allow you to peek at the browser internals and get back the information you need.

Noufal Ibrahim
A: 

you can alternatively try the gtkmozembed module. lets you run a firefox instance and load pages in there.

selenium might be best if you are just after load times, but if you want to do more interactions with the page, like execute javascript, or take screenshots even, gtkmozembed might be your man.

JiminyCricket
selenium executes javascript and takes screenshots, too.
nosklo