简体   繁体   English

webDriverException“selenium.common.exceptions.WebDriverException:消息:Service./webdrivers/geckodriver 意外退出。状态代码为:1”

[英]webDriverException "selenium.common.exceptions.WebDriverException: Message: Service ./webdrivers/geckodriver unexpectedly exited. Status code was: 1"

I am running a simple python based selenium webdriver script for geckodriver我正在为 geckodriver 运行一个简单的基于 python 的 selenium webdriver 脚本

from selenium import webdriver
geckodriver_path = "./webdrivers/geckodriver"
driver = webdriver.Firefox(executable_path=geckodriver_path)
driver.get("https://dev.to")
driver.find_element_by_id("nav-search").send_keys("Selenium")

after execution showing Warning message along with Exception执行后显示警告消息和异常

/<path>/demo.py:3: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
  driver = webdriver.Firefox(executable_path=geckodriver_path)

And the exception is例外是

selenium.common.exceptions.WebDriverException: Message: Service ./webdrivers/geckodriver unexpectedly exited. Status code was: 1

The environment which is being used正在使用的环境
python(3.9.2)蟒蛇(3.9.2)
selenium(4.1.0)硒(4.1.0)
geckodriver(0.24.0)壁虎驱动程序(0.24.0)
firefox(87.0 64-bit)火狐(87.0 64 位)

Output of geckodriver.log geckodriver.log 的 Output

error: Found argument '--websocket-port' which wasn't expected, or isn't valid in this context

USAGE:
    geckodriver [FLAGS] [OPTIONS]

For more information try --help

In Selenium after version 4, it's recommended to use Services, still don't know why, but if someone will find, it would be great to know.在Selenium版本4之后,推荐使用Services,还是不知道为什么,但是如果有人会发现,那就太好了。

To resolve you issue you could try this:要解决您的问题,您可以尝试以下操作:

from selenium.webdriver.firefox.service import Service as FXService
from selenium.webdriver import Firefox


search_by = 'xpath'
search_path = "//div[@id='header-search']/form/div/div/input"    

driver_path = './webdrivers/geckodriver'
driver = Firefox(service=FXService(driver_path))

driver.get("https://dev.to")
driver.find_element('xpath', div_path).send_keys("Selenium")

Hope this will be helpful!希望这会有所帮助!

It works after giving absolute path for variable geckodriver_path, also update geckodriver version to latest one.它在为变量 geckodriver_path 提供绝对路径后工作,还将 geckodriver 版本更新为最新版本。 (currently it is 0.30.0 which is compatible with firefox 87.0 64-bit ) (目前是 0.30.0 兼容 firefox 87.0 64-bit )

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 selenium.common.exceptions.WebDriverException:消息:Service.\geckodriver.exe 意外退出。 状态码为:3221225595 - selenium.common.exceptions.WebDriverException: Message: Service .\geckodriver.exe unexpectedly exited. Status code was: 3221225595 selenium.common.exceptions.WebDriverException:消息:服务geckodriver意外退出。 状态代码为:-11-如何解决? - selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: -11 - How to fix? selenium.common.exceptions.WebDriverException:消息:服务geckodriver意外退出。 状态码为:69 - selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 69 Docker Selenium:selenium.common.exceptions.WebDriverException:消息:服务chromedriver意外退出。 状态码为:127 - Docker Selenium: selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127 selenium.common.exceptions.WebDriverException:消息:服务意外退出。 状态码为:3221225595 - selenium.common.exceptions.WebDriverException: Message: Service unexpectedly exited. Status code was: 3221225595 selenium.common.exceptions.WebDriverException:消息:服务 chromedriver 意外退出。 状态码是:1 - selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 1 selenium.common.exceptions.WebDriverException:消息:chromedriver 意外退出。 状态码为:255 使用 Dockerfile 时 - selenium.common.exceptions.WebDriverException: Message: chromedriver unexpectedly exited. Status code was: 255 When using Dockerfile selenium.common.exceptions.WebDriverException:消息:服务 chromedriver 意外退出 - selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited WebDriverException:消息:服务 geckodriver 意外退出。 状态代码是:64 error using Selenium Geckodriver Firefox in FreeBSD jail - WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 64 error using Selenium Geckodriver Firefox in FreeBSD jail WebDriverException:消息:服务 chromedriver 意外退出。 状态代码为:127 - WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM