gpt4 book ai didi

selenium - NS_ERROR_SOCKET_ADDRESS_IN_USE

转载 作者:行者123 更新时间:2023-12-02 19:28:29 24 4
gpt4 key购买 nike

我的代码:

from selenium import webdriver
import selenium.webdriver.support.ui as ui
import time
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By

driver = webdriver.Firefox()
driver.get("https://www.youtube.com")
login_wait = WebDriverWait(driver, 10)

textbox = login_wait.until(EC.visibility_of_element_located((By.ID, 'search')))
textbox.send_keys("a")

time.sleep(10)
driver.close()

Python 控制台中没有错误,但 geckodriver.log:

1514074507756   geckodriver INFO    geckodriver 0.19.1
1514074507763 geckodriver INFO Listening on 127.0.0.1:49865
1514074508870 mozrunner::runner INFO Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "-marionette" "-profile" "/var/folders/kf/8800phd97vx28vtzdytqk1m80000gn/T/rust_mozprofile.oI7AzEUKweAr"
1514074509913 Marionette ERROR Error on starting server: [Exception... "Component returned failure code: 0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE) [nsIServerSocket.initSpecialConnection]" nsresult: "0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE)" location: "JS frame :: chrome://marionette/content/server.js :: MarionetteServer.prototype.start :: line 95" data: no]
[Exception... "Component returned failure code: 0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE) [nsIServerSocket.initSpecialConnection]" nsresult: "0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE)" location: "JS frame :: chrome://marionette/content/server.js :: MarionetteServer.prototype.start :: line 95" data: no]
MarionetteServer.prototype.start@chrome://marionette/content/server.js:95:19
MarionetteComponent.prototype.init@jar:file:///Applications/Firefox.app/Contents/Resources/omni.ja!/components/marionette.js:217:5
MarionetteComponent.prototype.handle@jar:file:///Applications/Firefox.app/Contents/Resources/omni.ja!/components/marionette.js:112:5

2017-12-23 19:15:11.556 plugin-container[42994:4077314] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x9b3b, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2017-12-23 19:15:11.559 plugin-container[42994:4077314] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x9e03, name = 'com.apple.CFPasteboardClient'
See /usr/include/servers/bootstrap_defs.h for the error codes.

最佳答案

如果您查看错误堆栈跟踪,错误说明了一切:

1514074509913   Marionette  ERROR   Error on starting server: [Exception... "Component returned failure code: 0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE) [nsIServerSocket.initSpecialConnection]"  nsresult: "0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE)"  location: "JS frame :: chrome://marionette/content/server.js :: MarionetteServer.prototype.start :: line 95"  data: no]

这本质上意味着 Marionette 正在尝试与您建立连接 localhost 127.0.0.1 通过端口 49865 但该端口当前由于以下原因之一而被占用:

  • Port 49865 当前正被在您的 localhost 之外运行的其他应用程序使用。
  • Port 49865 由您的 localhost 运行的某些服务使用
  • Port 49865 尚未被 WebDriver 的悬空实例释放。变体例如GeckoDriver , ChromeDriver , IEDriverServerGhostDriver .

解决方案:

解决方案是以下任一/所有步骤:

  • 始终使用 driver.quit() tearDown() 你的方法Automation Script 。如果 WebDriver 的任何悬空实例变体例如GeckoDriver , ChromeDriver , IEDriverServerGhostDriver存在于您的系统上,请以编程方式/手动杀死它们。
  • 确保 Port 49865 不被您的 localhost 运行的任何其他应用程序使用。
  • 确保 Port 49865 不被从 localhost 运行的某些服务使用
  • 使用CCleaner 执行 Tests 之前和之后的工具从您的系统中清除操作系统的杂务。
  • 采取 System Reboot
  • 如果问题仍然存在,uninstall <强> Mozilla Firefox Browser Revo Uninstaller 并安装 Mozilla Firefox Browser 的新实例

关于selenium - NS_ERROR_SOCKET_ADDRESS_IN_USE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47957107/

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