我正在尝试使用selenium-maven-plugin来自动运行Selenium IDE测试。测试暂时存储为HTML,所以我用“selenese”目标运行它们。下面是我的pom.xml文件。
运行“mvn”可以在我的Mac上运行Firefox。但是,Chrome(34)无法像Safari那样启动。 Chrome确实启动了,但它顶部显示一个黄色条,出现以下错误。我必须单击SSL警告才能运行测试。这可以防止自动化。
“您正在使用不受支持的命令行标志: - disable-web-security。稳定性和安全性将受到影响。”
它还会在我的控制台中打印一些奇怪的东西。
08:09:26.409 INFO - Launching Google Chrome...
08:09:33.718 INFO - Couldn't proxy to http://qwlflrjuwsed/ because host not found
08:09:33.767 INFO - Couldn't proxy to http://jnjairvl/ because host not found
08:09:33.927 INFO - Couldn't proxy to http://rbqnqivg/ because host not found
Safari有超时异常:
[ERROR] Failed to execute goal org.codehaus.mojo:selenium-maven-plugin:2.3:selenese (test)
on project palogic-web-tests: Execution test of goal org.codehaus.mojo:selenium-maven-
plugin:2.3:selenese failed. SeleniumCommandTimedOutException -> [Help 1]
在Windows上,由于锁定文件,Firefox无法启动。
[ERROR] Failed to execute goal org.codehaus.mojo:selenium-maven-plugin:2.3:selenese (test)
on project my-web-tests: Execution test of goal org.codehaus.mojo:selenium-maven-
plugin:2.3:selenese failed: Firefox refused shutdown while preparing a profile: Lock file
still present! C:\Tools\cygwin\tmp\customProfileDir699886\parent.lock -> [Help 1]
我的问题:这是由selenium-maven-plugin,selenese目标还是Selenium引起的“无法启动浏览器”问题?是否可以修复它以便测试可以自动化并且浏览器可以轻松启动?或者我应该研究其他解决方案,比如Geb?
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company</groupId>
<artifactId>my-web-tests</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<defaultGoal>verify</defaultGoal>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<browser>${browser}</browser>
<suite>src/test/selenium/testsuite.html</suite>
<startURL>https://siteiwanttotest.com/</startURL>
</configuration>
<executions>
<execution>
<id>test</id>
<phase>integration-test</phase>
<goals>
<goal>selenese</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<browser>*firefox</browser>
</properties>
<profiles>
<profile>
<id>chrome</id>
<properties>
<browser>*googlechrome</browser>
</properties>
</profile>
<profile>
<id>firefox</id>
<properties>
<browser>*firefox</browser>
</properties>
</profile>
<profile>
<id>ie</id>
<properties>
<browser>*iexplore</browser>
</properties>
</profile>
</profiles>
</project>