0

我是 Serenity Bdd 框架的新手;我克隆了这个仓库:https ://github.com/serenity-bdd/serenity-screenplay-train-demo

Os: Ubuntu: 17.04 
Intellij IDEA Community 2017.3 
Pom.xml: https://github.com/serenity-bdd/serenity-screenplay-train-demo/blob/master/pom.xml

<dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-core</artifactId>
            <version>${serenity.version}</version>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-screenplay</artifactId>
            <version>${serenity.version}</version>
        </dependency>

我正在尝试运行自动化测试,但遇到了错误:

net.thucydides.core.webdriver.UnsupportedDriverException: 
Could not instantiate class org.openqa.selenium.chrome.ChromeDriver
.
.
.
Caused by: net.thucydides.core.webdriver.UnsupportedDriverException: Could 
not instantiate new WebDriver instance of type class 
org.openqa.selenium.chrome.ChromeDriver (The path to the chromedriver driver 
executable must be set by the webdriver.chrome.driver system property; for 
more information, see 
https://sites.google.com/a/chromium.org/chromedriver/downloads. The latest 
version can be downloaded from 
https://sites.google.com/a/chromium.org/chromedriver/downloads
.
.
.
.
Caused by: java.lang.IllegalStateException: The path to the chromedriver 
driver executable must be set by the webdriver.chrome.driver system 
property; for more information, see 
https://sites.google.com/a/chromium.org/chromedriver/downloads. The latest 
version can be downloaded from 
https://sites.google.com/a/chromium.org/chromedriver/downloads

我知道我缺少一些罐子或库,但不知道如何添加它们或添加什么。我猜我应该更新 maven pom.xml 以添加缺少的依赖项?

更新:

原来pom.xml是指向旧的库版本,所以我更新了它们,现在得到了这个新错误:

错误 ntcore.webdriver.WebDriverFacade - 无法创建新的 WEBDRIVER_DRIVER 实例类 org.openqa.selenium.chrome.ChromeDriver:无法实例化类型为 org.openqa.selenium.chrome.ChromeDriver 的新 WebDriver 实例(chromedriver 驱动程序可执行文件的路径必须由 webdriver.chrome.driver 系统属性设置;有关更多信息,请参阅 https://sites.google.com/a/chromium.org/chromedriver/downloads。最新版本可以从 https://sites下载.google.com/a/chromium.org/chromedriver/downloads

4

1 回答 1

1

消息“FAILED TO CREATE NEW WEBDRIVER_DRIVER INSTANCE”表示 Selenium 无法连接到 WebDriver。消息的其余部分(“chromedriver 驱动程序可执行文件的路径必须由 webdriver.chrome.driver 系统属性设置...”)解释了您需要做什么。您需要下载最新的 chromedriver 可执行文件并将其放在系统路径中。Serenity 将为您设置 webdriver.chrome.driver 属性 - 不要,重复不要,在您的测试类或属性文件中硬编码此路径(硬编码 chromedriver 路径是一种常见但非常错误的反模式,因为它使您的测试非常难以移植)。

于 2018-01-06T13:52:01.693 回答