Google chrome 使用Selenium Maven插件通过Google Chrome运行Selenium 2.0 Selenese测试
我试图通过Google Chrome(版本12.0.742.100)上的Selenium maven插件(版本1.1)运行一些Selenium 2.0 HTML测试,在尝试执行Open命令后,我得到错误,无法调用未定义的方法'indexOf' 搜索之后,我们似乎应该使用--disable web security参数执行我们的chrome可执行文件,这对于Selenese目标来说并不容易。该插件似乎允许我们将chrome可执行文件的文件路径指定为Selenium Maven插件中参数的一部分,但它不允许我在调用中附加--disable web security。如果我尝试这样做,它将给出一个maven构建错误 我试图做的是将调用放在一个批处理文件中,然后指向我POM中的批处理文件,这就成功了。然而,最终的结果是,chrome浏览器启动了,没有进入测试运行程序,而是停留在我的主页上 我在这里的问题是,我在使用SeleniumMaven插件的Chrome中通过SeleniumEse测试指出的错误是否可以克服?如果不是,除了将测试转换为JUnits/TestNg测试之外,最好的方法是什么 请参阅下面我的POM文件的片段Google chrome 使用Selenium Maven插件通过Google Chrome运行Selenium 2.0 Selenese测试,google-chrome,maven-2,selenium,selenium-rc,selenium-webdriver,Google Chrome,Maven 2,Selenium,Selenium Rc,Selenium Webdriver,我试图通过Google Chrome(版本12.0.742.100)上的Selenium maven插件(版本1.1)运行一些Selenium 2.0 HTML测试,在尝试执行Open命令后,我得到错误,无法调用未定义的方法'indexOf' 搜索之后,我们似乎应该使用--disable web security参数执行我们的chrome可执行文件,这对于Selenese目标来说并不容易。该插件似乎允许我们将chrome可执行文件的文件路径指定为Selenium Maven插件中参数的一部分,但
....
<properties>
<selenium.version>2.0b3</selenium.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>1.1</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium</artifactId>
<version>${selenium.version}</version>
<type>pom</type>
<exclusions>
<!-- prevent ant:ant versus org.apache.ant:ant collision -->
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<executions>
<execution>
<id>Run-googlechrome-Script</id>
<phase>integration-test</phase>
<goals>
<goal>selenese</goal>
</goals>
<configuration>
<browser>*googlechrome</browser>
<suite>src/test/selenium/html/TestSuite.html</suite>
<startURL>http://localhost:5555/</startURL>
<results>${project.build.directory}/results/googlechrome-smoke-results.html</results>
<port>5555</port>
<timeoutInSeconds>5000</timeoutInSeconds>
<multiWindow>true</multiWindow>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
....
。。。。
2.0b3
org.codehaus.mojo
selenium maven插件
1.1
org.seleniumhq.selenium
硒
${selenium.version}
聚甲醛
蚂蚁
蚂蚁
运行googlechrome脚本
集成测试
赛琳娜语
*谷歌色素
src/test/selenium/html/TestSuite.html
http://localhost:5555/
${project.build.directory}/results/googlechrome-smoke-results.html
5555
5000
真的
....
谢谢
Juan尝试所需的功能-请参见此处: 因此,我建议您在@BeforeClass函数中使用如下内容:
@BeforeClass
public static void createAndStartService() {
service = new ChromeDriverService.Builder()
.usingChromeDriverExecutable(new File("path/to/my/chromedriver"))
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--disable-web-security"));
WebDriver driver = new ChromeDriver(capabilities);
顺便说一句,最好的方法是将chromedriver.exe存储在maven/src子目录中尝试所需的功能-请参见此处: 因此,我建议您在@BeforeClass函数中使用如下内容:
@BeforeClass
public static void createAndStartService() {
service = new ChromeDriverService.Builder()
.usingChromeDriverExecutable(new File("path/to/my/chromedriver"))
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--disable-web-security"));
WebDriver driver = new ChromeDriver(capabilities);
顺便说一句,最好的方法是将chromedriver.exe存储在maven/src子目录中