【问题标题】:How to replace Chrome with PhantomJS for use with Selenium and Conductor?如何用 PhantomJS 替换 Chrome 以与 Selenium 和 Conductor 一起使用?
【发布时间】:2016-10-05 09:40:22
【问题描述】:

我正在成功地使用 Conductor 框架从网站上抓取数据。我使用 Chrome 浏览器,因此我在项目的根目录中安装了 chromedriver.exe。

为了加快速度,我想用无头 PhantomJS 浏览器替换 Chrome。我按照 Stackoverflow 问题的答案中的说明安装了 PhantomJS:PhantomJS & Conductor Framework,并将浏览器更改为 @Config 中的 Browser.PHANTOMJS。

然而,无论我做什么,我都没有得到任何结果。

我没有找到如何设置 PhantomJS 以与 Selenium 或 PhantomJS 一起使用的文档。

How to Implement Selenium WebDriver with PhantomJS and Can we Use Sikuli with PhantomJS? 的问题也没有帮助。

如何将 Chrome 替换为 PhantomJS 以用于 Selenium 和 Conductor?

【问题讨论】:

    标签: selenium selenium-webdriver phantomjs conductor-framework


    【解决方案1】:

    您遇到的问题似乎是由于 Conductor 中包含的 PhantomJS 库的旧版本。运行 PhantomJS 时的错误可以在 Selenium Github 上的this imported issue 中找到。补救措施是导入 PhantomJS 的 fork,它适用于 Selenium 的较新版本。

    您可以通过编辑pom.xml 文件并交换来轻松实现这一点

    <groupId>com.github.detro</groupId>
    <artifactId>phantomjsdriver</artifactId>
    <version>${phantomjs_version}</version>
    

    <groupId>com.codeborne</groupId>
    <artifactId>phantomjsdriver</artifactId>
    <version>1.2.1</version>
    

    【讨论】:

    • 作为指挥的创造者,我可以告诉你,这解决了这个问题。修复has been merged,但我可能需要一段时间才能发布。当我迁移主机时,我的 CI 东西搞砸了。
    • 成功了。 @sircapsalot Conductor 是一个真正伟大的框架。在不了解 Selenium 的情况下,它几乎立即让我提高了工作效率。
    【解决方案2】:

    您可以使用带有 selenium 的无头 chrome 驱动程序,如下所示:

    https://duo.com/decipher/driving-headless-chrome-with-python

    【讨论】:

      猜你喜欢
      • 2013-07-19
      • 1970-01-01
      • 2016-07-18
      • 1970-01-01
      • 1970-01-01
      • 2013-07-11
      • 2016-02-25
      • 2022-01-22
      • 1970-01-01
      相关资源
      最近更新 更多