【发布时间】:2013-06-30 21:58:21
【问题描述】:
我遇到了 Selenium 问题,无法让它工作。
我想做什么:
我们的一个客户向我们发送了一个 Selenium 测试用例,该用例将在多个位置自动执行并记录所用时间。
我们想使用 Selenium 和 Firefox Portable,因为我们想让测试完全独立于任何用户输入和在不同位置安装的软件。
开始条件就这么多;)
到目前为止我们做了什么:
第一个版本完全用 Java 编写,我们使用 Selenium IDE Plugin -> Export to Java WebDriver 将客户的测试用例导出到 Java。
这不能再做,因为客户现在使用 WebDriver 导出不支持的一些功能。由于我们不想改变客户的测试,Java 导出不再是一种选择。
所以对于第一次运行,我们使用这个命令(任何变量都设置正确):
java -jar selenium-2.33.0/selenium-server-standalone-2.33.0.jar -port 5555
-firefoxProfileTemplate "Firefox\Data\profile" -log logs\selenium_server.log
-htmlSuite "*firefox" http://localhost:5555 Testsuite.html
logs\results-firefox-%curTimestamp%.html
这会启动我预装的 Firefox,而不是便携式的。在客户机器上,没有启动任何 Firefox,因为它没有安装。所以我不得不使用“自定义”htmlSuite来提供Firefox的路径:
java -jar selenium-2.33.0/selenium-server-standalone-2.33.0.jar -port 5555
-firefoxProfileTemplate "Firefox\Data\profile" -log logs\selenium_server.log
-htmlSuite "*custom %FF_DIR%\FirefoxPortable.exe" http://localhost:5555 Testsuite.html
logs\results-firefox-%curTimestamp%.html
这不起作用,因为如果在 Windows 下运行,Selenium 服务器将无法执行此命令,我们这样做(请参阅:http://code.google.com/p/selenium/issues/detail?id=3274)
由于评论 #6 有一些差异,我们修补了 selenium Server 独立 Jar 并再次运行测试。现在可以启动浏览器,但无法运行测试。加载第一页后,我们收到错误“访问属性'文档'的权限被拒绝”。
此处的解决方案表明,用户权限问题可能是原因,您应该尝试“chrome”htmlSuite(请参阅:https://sqa.stackexchange.com/questions/1453/how-to-fix-permission-denied-to-access-property-document)
所以我们做到了:
java -jar selenium-2.33.0/selenium-server-standalone-2.33.0-patched.jar
-port 5555 -firefoxProfileTemplate "FirefoxPortable\Data\profile"
-log logs\selenium_server.log -htmlSuite "*chrome %FF_DIR%\FirefoxPortable.exe"
http://localhost:5555 Testsuite.html logs\results-firefox-%curTimestamp%.html
请注意我们的“修补”硒和“铬”htmlSuite。 那也没用。 所以,简而言之,结果如下:
htmlSuite = firefox:使用预装的 Firefox(如果已安装),而不是便携式的。如果没有安装FF,则测试完全失败
htmlSuite = chrome:服务器无法启动浏览器,因为它试图设置 EnvironmentVariables,运行 Windows 时不支持(请参阅:http://code.google.com/p/selenium/source/browse/java/client/src/org/openqa/selenium/os/WindowsProcessGroup.java#67 以下第 67 行)
htmlSuite = googleChrome: Google Chrome Portable 可以启动,但是 Chrome 浏览器找不到测试指定的某些元素,所以我们不能使用 Chrome(更改测试是没有选择的,如上所述)
htmlSuite = iexplore: Internet Explorer 启动,但随后出现 JavaScript 错误,引用由 Selenium 创建的自定义配置文件,因此测试在 IE 中也不起作用
htmlSuite = custom:Portable Firefox 已启动 (yeehaw),但没有足够的权限执行测试。
【问题讨论】:
标签: selenium