在Mac上使用Python控制浏览器

GJ.*_*GJ. 9 python browser safari firefox automation

我正在寻找一种使用Python以编程方式控制Mac上的浏览器(即Firefox或Safari或Chrome/-ium或Opera,但不是IE)的方法.

我需要的操作包括以下链接,检查页面中是否存在元素,以及提交表单.

你会推荐哪种解决方案?

dig*_*mer 7

我喜欢Selenium,它可以通过Python编写脚本.Selenium IDE仅在Firefox中运行,但Selenium RC支持多种浏览器.


GJ.*_*GJ. 0

看一下PyShell(PyXPCOM 的扩展)。

例子:

promptSvc = components.classes["@mozilla.org/embedcomp/prompt-service;1"].\
        getService(Components.interfaces.nsIPromptService)
promptSvc.alert(None, 'Greeting...', "Hello from Python")
Run Code Online (Sandbox Code Playgroud)

Python PyShell 0.1,Mozilla,弹出窗口,OK