我有一个由thucydides-jbehave-archetype
构建的项目我正在尝试按照这些步骤更改Thucydides运行的浏览器,当我运行projectL http://thucydides.info/docs/thucydides/_running_thucydides_in_different_browsers.html时
在pom.xml中我有这个(来自thucydides原型):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
根据说明,我已将其更改为:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<!--
<configuration>
<skip>true</skip>
</configuration>
-->
<configuration>
<systemPropertyVariables>
<webdriver.driver>${webdriver.driver}</webdriver.driver>
</systemPropertyVariables>
</configuration>
</plugin>
我还更改了属性部分中的值:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<thucydides.version>0.9.205</thucydides.version>
<thucydides.jbehave.version>0.9.205</thucydides.jbehave.version>
<!-- I have tried chrome too -->
<webdriver.driver>safari</webdriver.driver>
</properties>
但我的测试仍然使用默认浏览器(firefox)运行。我在这里做错了什么?
答案 0 :(得分:2)
我遇到了与systemPropertyVariables相同的问题,我决定不使用pom.xml。
您需要创建类* TestSuite并从类ThucydidesJUnitStories扩展它。 在构造函数中,您只需设置所需的属性。
import net.thucydides.core.ThucydidesSystemProperty; import net.thucydides.jbehave.ThucydidesJUnitStories;public class PremiumTestSuite extends ThucydidesJUnitStories {
public PremiumTestSuite() { System.setProperty("webdriver.chrome.driver", System.getProperty("user.home") + "/chromedriver"); getSystemConfiguration().setIfUndefined("webdriver.driver", "chrome"); getSystemConfiguration().setIfUndefined(ThucydidesSystemProperty.THUCYDIDES_STORE_HTML_SOURCE.getPropertyName(), "true"); getSystemConfiguration().setIfUndefined(ThucydidesSystemProperty.THUCYDIDES_TAKE_SCREENSHOTS.getPropertyName(), "FOR_FAILURES"); } }
我希望它会对你有所帮助:)。