我遇到问题,在运行自动化测试时,我无法让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
然后我将firefox的功能性selenium测试作为www-data用户运行:
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?
答案 0 :(得分:4)
似乎Selenium的每个版本仅支持最新的稳定版Firefox。如下所述:
每个版本的Selenium仅支持Firefox N,N-1,ESR和& ESR-1,其中N是Firefox稳定版>发布时的频道和ESR是当前的ESR版本。这意味着对于Selenium 2.42我们>支持Firefox 31(N / ESR),30(N-1),24(ESR - 1)。我们应该在>范围内发布2.43版本。一周,将支持32(N),31(N-1 / ESR),24(ESR -1)
您是否厌倦了更新Selenium或尝试使用较旧版本的Firefox?