我一直在Linux中运行Selenium测试,我收到以下错误:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: no display specified
谷歌搜索后我可以看到我需要export DISPLAY=:0
来解决这个问题。
然而,我不清楚为什么需要这样做。
答案 0 :(得分:0)
安装xvnc,
然后只需输入
即可启动它vncserver
此后终端要求输入密码短语,并返回显示号码。
导出该显示号码以启用selenium以在该虚拟显示器上启动firefox浏览器。
您可以这样导出
export DISPLAY=:1 # Assuming 1 is the display number returned.
使用上述步骤有望为您提供更多有关出口/显示内容的原因。然而,导出的原因是提供虚拟显示以便firefox“正常”启动,而selenium可以使用本机交互与其进行交互。
答案 1 :(得分:0)
你可以用更多的规范重新表达你的qs,比如你正在使用的操作系统,你使用的是哪个selenium jar用于编写测试用例的N-unit框架以及你用于编写哪种Programmibg语言测试案例?
我也遇到了同样的问题,通过以下步骤解决了这个问题: 我有旧的selemium-server-standalone-jar我把它更新到最新的2.40 我有旧的FF版本I工具FF 29。 我使用junit进行测试用例设计,它对我有用。
当我使用Windows机器时,请告诉我你是否有意义。问题是:
xception: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
ser\\AppData\\Local\\Temp\\anonymous6184290163469300810webdriver-profile\\extensions\\fxdriver@googlecode.com","mtime":1401260795981,"rdfTime":1401260791866}}}]
*** LOG addons.xpi-utils: Opening XPI database C:\Users\user\AppData\Local\Temp\anonymous6184290163469300810webdriver-profile\extensions.json
*** LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
*** LOG addons.xpi-utils: Make addon app-profile:fxdriver@googlecode.com visible
*** LOG DeferredSave/extensions.json: Save changes
*** LOG DeferredSave/extensions.json: Save changes
*** LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
*** LOG addons.xpi-utils: Make addon app-global:{972ce4c6-7e08-4474-a285-3208198ce6fd} visible
*** LOG DeferredSave/extensions.json: Save changes
*** LOG DeferredSave/extensions.json: Save changes
*** LOG addons.xpi: New add-on otis@digitalpersona.com installed in winreg-app-global
*** LOG addons.xpi-utils: Make addon winreg-app-global:otis@digitalpersona.com visible
*** LOG DeferredSave/extensions.json: Save changes
*** LOG DeferredSave/extensions.json: Save changes
*** LOG addons.xpi: New add-on ext@VideoPlayerV3beta652.net installed in winreg-app-global
*** LOG addons.xpi-utils: Make addon winreg-app-global:ext@VideoPlayerV3beta652.net visible
*** LOG DeferredSave/extensions.json: Save changes
*** LOG DeferredSave/extensions.json: Save changes
*** LOG addons.xpi: New add-on ext@MediaPlayerV1alpha512.net installed in winreg-app-global
*** LOG addons.xpi-utils: Make addon winreg-app-global:ext@MediaPlayerV1alpha512.net visible
*** LOG DeferredSave/extensions.json: Save changes
*** LOG DeferredSave/extensions.json: Save changes
*** LOG addons.xpi: New add-on {55A8EC97-6AF6-442c-877F-11C51DBD162D} installed in winreg-app-global
*** LOG addons.xpi-utils: Make addon winreg-app-global:{55A8EC97-6AF6-442c-877F-11C51DBD162D} visible
*** LOG DeferredSave/extensions.json: Save changes
*** LOG DeferredSave/extensions.json: Save changes
*** LOG addons.xpi: Updating database with changes to installed add-ons
*** LOG addons.xpi-utils: Updating add-on states
*** LOG addons.xpi-utils: Writing add-ons list
*** LOG DeferredSave/extensions.json: Starting timer
*** LOG DeferredSave/extensions.json: Starting write
*** LOG DeferredSave/extensions.json: Write succeeded
*** LOG addons.xpi-utils: XPI Database saved, setting schema version preference to 16
*** LOG addons.manager: shutdown
*** LOG addons.xpi: shutdown
*** LOG addons.xpi-utils: shutdown
*** LOG addons.xpi: Notifying XPI shutdown observers
*** LOG addons.manager: Async provider shutdown done
System JS : ERROR resource://gre/modules/BookmarkHTMLUtils.jsm:798 - NS_ERROR_UNEXPECTED: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsINavBookmarksService.removeFolderChildren]
System JS : ERROR resource://app/components/nsBrowserGlue.js:1713 - NS_ERROR_UNEXPECTED: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIAnnotationService.getItemsWithAnnotation]
System JS : ERROR resource://gre/modules/BookmarkHTMLUtils.jsm:835 - NS_ERROR_UNEXPECTED: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsINavBookmarksService.runInBatchMode]
*** LOG addons.xpi: startup
*** LOG addons.xpi: Skipping unavailable install location app-system-local
*** LOG addons.xpi: Skipping unavailable install location app-system-share
*** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: C:\Users\user\AppData\Local\Temp\anonymous6184290163469300810webdriver-profile\extensions\webdriver-staging
*** LOG addons.xpi: checkForChanges
*** LOG addons.xpi: No changes found
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
JavaScript error: chrome://browser/content/urlbarBindings.xml, line 650: aUrl is undefined
*** LOG addons.manager: shutdown
*** LOG addons.xpi: shutdown
*** LOG addons.xpi: Notifying XPI shutdown observers
*** LOG addons.manager: Async provider shutdown done
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:106)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)