Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser automation: Python + Firefox using PyXPCOM

I have tried Pamie a browser automation library for internet explorer. It interfaces IE using COM, pretty neat:

import PAM30
ie = PAM30.PAMIE("http://user-agent-string.info/")
ie.clickButton("Analyze my UA")

Now I would like to do the same thing using PyXPCOM with similar flexibility on Firefox. How can I do this? Can you provide sample code?

update: please only pyxpcom

like image 366
George Avatar asked Jun 19 '09 23:06

George


2 Answers

I've used webdriver with firefox. I was very pleased with it.

As for the code examples, this will get you started.

like image 109
Geo Avatar answered Sep 22 '22 11:09

Geo


My understanding of PyXPCOM is that it's meant to let you create and access XPCOM components, not control existing ones. You may not be able to do this using PyXPCOM at all, per Mark Hammond, the original author:

It simply isn't what XPCOM is trying to do. I'm not sure if Mozilla/Firefox now has or is developing a COM or any other "automation" mechanism.

and:

If by "automating", you mean "controlling Mozilla via a remote process via xpcom", then as far as I know, that is not possible

You may instead want to take a look at the previously-suggested Webdriver project, Windmill, or MozMill, both of which support automating Firefox/Gecko/XULRunner via Python.

like image 22
Vitorio Avatar answered Sep 25 '22 11:09

Vitorio