【问题标题】:Browser automation: Python + Firefox using PyXPCOM浏览器自动化:Python + Firefox 使用 PyXPCOM
【发布时间】:2010-11-04 11:11:20
【问题描述】:

我尝试了Pamie 一个用于 Internet Explorer 的浏览器自动化库。它使用 COM 接口 IE,非常简洁:

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

现在我想在 Firefox 上使用 PyXPCOM 以类似的灵活性做同样的事情。我怎样才能做到这一点?能否提供示例代码?

更新:请仅使用 pyxpcom

【问题讨论】:

  • 冷静的家伙。有很多人在提出问题时假设他们已经知道答案。有时最好的解决方案不是他们所关注的。由于您没有提到为什么您需要 PyXPCOM 而不是许多其他自动化选项,因此提供您可能没有考虑过的替代方案并没有什么坏处。迟早会有 PyXPCOM 经验的人给你你需要的答案,如果没有,那么其他答案就无关紧要了。至少,他们可能会为其他偶然发现您在搜索“浏览器自动化”的问题的用户解决问题。

标签: python firefox automation


【解决方案1】:

我在 Firefox 中使用过 webdriver。我对此非常满意。

至于代码示例,this 将帮助您入门。

【讨论】:

    【解决方案2】:

    我对 PyXPCOM 的理解是,它旨在让您创建和访问 XPCOM 组件,而不是控制现有的组件。根据原作者 Mark Hammond 的说法,您可能根本无法使用 PyXPCOM 做到这一点:

    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.

    和:

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

    您可能想看看之前推荐的 Webdriver 项目 WindmillMozMill,它们都支持通过 Python 自动化 Firefox/Gecko/XULRunner。

    【讨论】:

      【解决方案3】:

      如果您正在测试 web 应用并想编写 Python 来执行此操作,请查看 Selenium RC,以便您可以为所有浏览器使用相同的 API。

      【讨论】:

        猜你喜欢
        • 2011-01-20
        • 2020-11-05
        • 2010-09-30
        • 1970-01-01
        • 2013-08-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-10-22
        相关资源
        最近更新 更多