【发布时间】:2014-10-20 19:50:43
【问题描述】:
在运行自动化测试时,我遇到了无法让 firefox 与 selenium 同步的问题。当我运行 selenium 服务器和 firefox phpunit 测试时,firefox 不断超时(显然),因为它无法连接到适当的端口。当我自己连接时,我收到某种码头 403 错误“禁止代理”,但我真的不知道如何解决这个问题。
如何调试它以确定问题出在哪里?
有关日志和错误消息的更多详细信息如下:
我启动 selenium 服务器:
java -jar selenium-server-standalone-2.42.2.jar
Oct 20, 2014 2:44:09 PM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
14:44:09.957 INFO - Java: Oracle Corporation 25.25-b02
14:44:09.957 INFO - OS: Linux 3.2.0-70-generic amd64
14:44:09.964 INFO - v2.42.2, with Core v2.42.2. Built from revision 6a6995d
14:44:10.048 INFO - Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match with current platform: LINUX
14:44:10.086 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
14:44:10.088 INFO - Version Jetty/5.1.x
14:44:10.089 INFO - Started HttpContext[/selenium-server,/selenium-server]
14:44:10.111 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@725bef66
14:44:10.111 INFO - Started HttpContext[/wd,/wd]
14:44:10.111 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
14:44:10.111 INFO - Started HttpContext[/,/]
14:44:10.115 INFO - Started SocketListener on 0.0.0.0:4444
14:44:10.115 INFO - Started org.openqa.jetty.jetty.Server@30dae81
然后我以 www-data 用户身份运行 firefox 的功能硒测试:
sudo -u www-data ../../vendor/bin/phpunit -c refox.xml functional
PHPUnit 3.7.37 by Sebastian Bergmann.
Configuration read from /srv/xxx/protected/tests/firefox.xml
PHP Notice: Undefined offset: 1 in /srv/xxx/protected/extensions/webdriver-bindings/phpwebdriver/WebDriver.php on line 58
FCurrent URL: (Unknown)
Current Title: (Unknown)
Screenshot file: /srv/xxx/protected/tests/output/test.failed.1413831941.6997.png
现在,据我所知,硒的相关错误是:
15:40:30.768 WARN - Exception: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
@googlecode.com visible
1413833983888 DeferredSave.extensions.json DEBUG Save changes
1413833983889 DeferredSave.extensions.json DEBUG Save changes
1413833983889 addons.xpi DEBUG New add-on langpack-en-GB@firefox.mozilla.org installed in app-global
1413833983896 addons.xpi-utils DEBUG Make addon app-global:langpack-en-GB@firefox.mozilla.org visible
1413833983896 DeferredSave.extensions.json DEBUG Save changes
1413833983896 DeferredSave.extensions.json DEBUG Save changes
1413833983898 addons.xpi DEBUG New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
1413833983900 addons.xpi-utils DEBUG Make addon app-global:{972ce4c6-7e08-4474-a285-3208198ce6fd} visible
1413833983900 DeferredSave.extensions.json DEBUG Save changes
1413833983900 DeferredSave.extensions.json DEBUG Save changes
1413833983900 addons.xpi DEBUG New add-on langpack-en-ZA@firefox.mozilla.org installed in app-global
1413833983906 addons.xpi-utils DEBUG Make addon app-global:langpack-en-ZA@firefox.mozilla.org visible
1413833983906 DeferredSave.extensions.json DEBUG Save changes
1413833983906 DeferredSave.extensions.json DEBUG Save changes
1413833983907 addons.xpi DEBUG New add-on ubufox@ubuntu.com installed in app-system-share
1413833983910 addons.xpi-utils DEBUG Make addon app-system-share:ubufox@ubuntu.com visible
1413833983910 DeferredSave.extensions.json DEBUG Save changes
1413833983910 DeferredSave.extensions.json DEBUG Save changes
1413833983915 addons.xpi DEBUG Updating database with changes to installed add-ons
1413833983915 addons.xpi-utils DEBUG Updating add-on states
1413833983916 addons.xpi-utils DEBUG Writing add-ons list
1413833983917 addons.xpi DEBUG Registering manifest for /usr/lib/firefox/browser/extensions/langpack-en-GB@firefox.mozilla.org.xpi
1413833983918 addons.xpi DEBUG Registering manifest for /usr/lib/firefox/browser/extensions/langpack-en-ZA@firefox.mozilla.org.xpi
1413833984887 DeferredSave.extensions.json DEBUG Starting timer
1413833984920 addons.manager DEBUG shutdown
1413833984921 DeferredSave.extensions.json DEBUG Starting write
1413833984922 addons.xpi DEBUG shutdown
1413833984922 addons.xpi-utils DEBUG shutdown
1413833984986 DeferredSave.extensions.json DEBUG Write succeeded
1413833984986 addons.xpi-utils DEBUG XPI Database saved, setting schema version preference to 16
1413833984986 addons.xpi DEBUG Notifying XPI shutdown observers
1413833984990 addons.manager DEBUG Async provider shutdown done
1413833985681 addons.manager DEBUG Loaded provider scope for resource://gre/modules/addons/XPIProvider.jsm: ["XPIProvider"]
1413833985682 addons.manager DEBUG Loaded provider scope for resource://gre/modules/LightweightThemeManager.jsm: ["LightweightThemeManager"]
1413833985685 addons.xpi DEBUG startup
1413833985686 addons.xpi INFO Mapping ubufox@ubuntu.com to /usr/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/ubufox@ubuntu.com
1413833985686 addons.xpi INFO Mapping langpack-en-GB@firefox.mozilla.org to /usr/lib/firefox/browser/extensions/langpack-en-GB@firefox.mozilla.org.xpi
1413833985686 addons.xpi INFO Mapping {972ce4c6-7e08-4474-a285-3208198ce6fd} to /usr/lib/firefox/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}
1413833985687 addons.xpi INFO Mapping langpack-en-ZA@firefox.mozilla.org to /usr/lib/firefox/browser/extensions/langpack-en-ZA@firefox.mozilla.org.xpi
1413833985687 addons.xpi DEBUG Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous6261528948184700600webdriver-profile/extensions/webdriver-staging
1413833985687 addons.xpi INFO Mapping fxdriver@googlecode.com to /tmp/anonymous6261528948184700600webdriver-profile/extensions/fxdriver@googlecode.com
1413833985688 addons.xpi DEBUG checkForChanges
1413833985692 addons.xpi DEBUG No changes found
1413833985695 addons.xpi DEBUG Registering manifest for /usr/lib/firefox/browser/extensions/langpack-en-GB@firefox.mozilla.org.xpi
1413833985696 addons.xpi DEBUG Registering manifest for /usr/lib/firefox/browser/extensions/langpack-en-ZA@firefox.mozilla.org.xpi
*** Blocklist::_preloadBlocklistFile: blocklist is disabled
15:41:08.028 INFO - Executing: [new session: Capabilities [{nativeEvents=false, name=AmericaTest-firefox, browserName=firefox, javascriptEnabled=true, version=}]])
15:41:08.029 INFO - Creating a new session for Capabilities [{nativeEvents=false, name=AmericaTest-firefox, browserName=firefox, javascriptEnabled=true, version=}]
当我在 google chrome 或 firefox 中手动连接到 127.0.0.1:7055 时,它会得到错误页面:
HTTP ERROR: 403
Forbidden for Proxy
RequestURI=/
Powered by Jetty://
但我可以连接到显示这个 selenium 小部件的 http://127.0.0.1:4444/wd/hub/
点击“创建会话”会创建一个空白的 firefox 页面,就像测试一样。
是的,我如何强制 firefox 测试使用适当的端口,并确保该代理端口已全部设置为 selenium?
【问题讨论】: