python中的selenium测试停止工作。selenium.common.exceptions异常.WebDriverException:消息:运行时连接被拒绝

2024-04-23 14:07:31 发布

您现在位置:Python中文网/ 问答频道 /正文

python中使用selenium的unittest停止工作。显示一个“连接被拒绝”(如标题所示)。geckoderver.log文件显示以下内容

1559581388377   geckodriver     INFO    Listening on 127.0.0.1:54601
1559581389320   mozprofile::profile     INFO    Using profile path /tmp/rust_mozprofile.zyb58n9FmLlx
1559581389321   geckodriver::marionette INFO    Starting browser /usr/bin/firefox
1559581389323   geckodriver::marionette INFO    Connecting to Marionette on localhost:32931
1559581390007   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
1559581390007   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
1559581390007   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader*
1559581393609   Marionette      INFO    Listening on port 2828
console.error: BroadcastService:
  receivedBroadcastMessage: handler for
  remote-settings/monitor_changes
  threw error:
  Message: Error: Polling for changes failed: NetworkError when attempting to fetch resource..
  Stack:
    remoteSettingsFunction/remoteSettings.pollChanges@resource://services-settings/remote-settings.js:190:13

1559581450024   geckodriver     INFO    Listening on 127.0.0.1:47318
1559581451024   mozprofile::profile     INFO    Using profile path /tmp/rust_mozprofile.FDdsjfOq9aQT
1559581451026   geckodriver::marionette INFO    Starting browser /usr/bin/firefox
1559581451029   geckodriver::marionette INFO    Connecting to Marionette on localhost:44244
1559581451840   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
1559581451840   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
1559581451840   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader*
1559581457209   Marionette      FATAL   Remote protocol server failed to start: Error: Could not bind to port 2828 (NS_ERROR_SOCKET_ADDRESS_IN_USE)(chrome://marionette/content/server.js:87:17) JS Stack trace: set acceptConnections@server.js:87:17
start@server.js:118:5
init/<@marionette.js:468:9
JavaScript error: jar:file:///usr/lib/firefox/omni.ja!/components/nsUrlClassifierListManager.js, line 329: NS_ERROR_NOT_INITIALIZED: Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIUrlClassifierDBService.getTables]
JavaScript error: jar:file:///usr/lib/firefox/omni.ja!/components/nsUrlClassifierListManager.js, line 329: NS_ERROR_NOT_INITIALIZED: Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIUrlClassifierDBService.getTables]

升级到 geckodriver至0.24.0(2019-01-28) Mozilla Firefox 66.0.3版

使用了spliter函数:Browser(firefox\u binary=“/usr/bin/firefox”)

from splinter import Browser

browser = Browser(firefox_binary="/usr/bin/firefox")
browser.visit( 'https://www.google.com' )
browser.fill( 'q', 'splinter - python acceptance testing for web application' )
browser.quit()

浏览器像以前一样弹出打开,但是url字符串中没有显示任何内容,浏览器几乎立即消失,然后终端显示“connection rejected”消息


Tags: orgbrowserinfomozillausrextensionjsfirefox