gpt4 book ai didi

firefox - Selenium 创建空白的 Firefox 浏览器窗口,然后该窗口不执行任何操作,而是运行 selenium 浏览器测试

转载 作者:行者123 更新时间:2023-12-02 18:39:39 26 4
gpt4 key购买 nike

在运行自动化测试时,我遇到了无法让 Firefox 与 Selenium 同步的问题。当我运行 selenium 服务器和 firefox phpunit 测试时,firefox 不断超时(显然),因为它无法连接到适当的端口。当我自己连接时,我收到某种 jetty 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 的功能性 Selenium 测试:

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

现在,据我所知,selenium 的相关错误是:

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://

但是我可以连接到http://127.0.0.1:4444/wd/hub/,它显示了这个selenium小部件

the selenium hub page

点击“创建 session ”会创建一个空白的 Firefox 页面,就像测试所做的那样。

the hub creates blank sessions, to be expected, but this is all the tests do too

那么,是的,我如何强制 Firefox 测试使用适当的端口,并确保该代理端口已全部设置为 selenium?

最佳答案

似乎每个版本的 Selenium 都只支持最新稳定版本的 Firefox。如下所述:

Each release of Selenium only supports Firefox N, N-1, ESR, & ESR-1 where N is the Firefox stable > channel at the time of release and ESR is the current ESR release. This means for Selenium 2.42 we > support Firefox 31 (N/ESR), 30 (N-1), 24 (ESR - 1). We should have the 2.43 release out within the > week, which will support 32 (N), 31 (N-1/ESR), 24 (ESR -1)

您是否厌倦了更新 Selenium 或尝试使用旧版本的 Firefox?

关于firefox - Selenium 创建空白的 Firefox 浏览器窗口,然后该窗口不执行任何操作,而是运行 selenium 浏览器测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26473749/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com