【问题标题】:How to use Arquillian Graphene 2 with ChromeDriver如何在 ChromeDriver 中使用 Arquillian Graphene 2
【发布时间】:2016-08-10 09:40:14
【问题描述】:

如何在 Chrome 等不同浏览器中使用 Graphene 2? (默认的 htmlUnit 不适合我。)

在 Arquillian 容器中运行 Wildfly 8.1 服务器,我想使用 Drone + Graphene 来执行实际测试。

@Drone
WebDriverdriver;

...

@RunAsClient
@Test
@InSequence(1)
public void basicHomepageTest() {

    // try to get the homepage
    driver.get("http://localhost:8080/superapp");

    // read title and source
    Assert.assertEquals("My Super App", driver.getTitle());

    // read content
    System.out.println("Page source -----");
    System.out.println(driver.getPageSource());
}

我尝试将其添加到 arquillian.xml 配置中(没有运气):

<extension qualifier="webdriver">
    <property name="browser">chrome</property>
</extension>

结束:

java.lang.RuntimeException: Unable to instantiate Drone via org.openqa.selenium.chrome.ChromeDriver(Capabilities): java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/se
    lenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
    Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleap
    is.com/index.html

我真的需要以某种方式将 Chrome 二进制文件嵌入到我的项目中吗?

【问题讨论】:

标签: jboss-arquillian arquillian-drone graphene2


【解决方案1】:

您不必将它本身嵌入到您的项目中,但 Chrome 的驱动程序并未随浏览器本身提供。您必须下载它并在配置文件中使用 chromeDriverBinary 将 Graphene 指向它的位置。

【讨论】:

    【解决方案2】:

    只是为了补充 bartozs 的回答,这就是我所做的:

    1) 为我的操作系统下载了 chromedriver 二进制文件here

    2) 将二进制路径添加到 arquillian.xml

    <extension qualifier="webdriver">
        <property name="browser">chrome</property>
        <property name="chromeDriverBinary">webdriver-bin/chrome/chromedriver.exe</property>
    </extension>
    

    【讨论】:

    • 你也可以把它放在你的系统/用户环境路径上,这样你就不必硬编码一个特定的路径了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-07
    • 2018-03-31
    • 2019-09-22
    • 1970-01-01
    相关资源
    最近更新 更多