社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

“WebDriverException:消息:无效参数:无法终止已退出的进程”CentOS 7 on VPS,Geckodriver v0.24.0和Firefox60,Selenium Python

SavagePotato • 7 年前 • 2367 次点击  

服务器:覆盆子皮3
操作系统:Dietpi-159版
壁虎版本:手臂0.22
火狐版本:52.9.0
python版本:3.5
硒版本:3.14.1

gecko是可执行的,位于/usr/local/bin中/

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



options = Options()
options.set_headless(headless=True)
driver = webdriver.Firefox(firefox_options=options)

print('Need your login credential')
username = input('What is your username?:\n')
password = input('What is your password?:\n')
...
...

输出:

root@RPi3:~# python3.5 ITE-bot.py 
Traceback (most recent call last):
  File "ITE-bot.py", line 12, in <module>
    driver = webdriver.Firefox(firefox_options=options)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
    keep_alive=True)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process

知道怎么了吗?我试过谷歌,但运气不好。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/43281
文章 [ 6 ]  |  最新文章 7 年前
Daniel Butler
Reply   •   1 楼
Daniel Butler    7 年前

我可以用xvfb运行测试来解决这个问题。我在远程服务器上运行它们。

我用的是詹金斯,所以我检查了这个盒子,看起来是这样的:

Credit to https://www.obeythetestinggoat.com/book/chapter_CI.html

学分 https://www.obeythetestinggoat.com/book/chapter_CI.html

flow3r
Reply   •   2 楼
flow3r    7 年前

我用过:

  • VS代码
  • linunx/ubuntu:18.10版本
  • 夜班表.js

我的问题是我试着运行夜班表(它会自动启动壁虎河) 从 vs码终端。

akostadinov Rogelio
Reply   •   3 楼
akostadinov Rogelio    7 年前

我是在无头模式下,使用所有东西的正确版本,唯一摆脱这个错误消息的方法是 不 以根用户身份执行硒测试

conde
Reply   •   4 楼
conde    7 年前

是选中“在生成可以解决问题之前启动xvfb”,但如果您有管道或多分支管道之类的作业,则此选项不可见。在Selenium网格的节点中执行所需的测试:

1-安装xvfb: apt install xvfb

2-执行xvfb: /usr/bin/Xvfb :99 -ac -screen 0 1024x768x8 & export DISPLAY=":99"

3-重新运行节点,例如: java -jar selenium.jar -role node -hub http://#.#.#.#:4444/grid/register -capabilities browserName=firefox,plataform=linux -host #.#.#.# -port 1991

hidehara NFern
Reply   •   5 楼
hidehara NFern    7 年前

如果在没有显示的系统上运行firefox,请确保使用无头模式。

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)

另外,请确保您有兼容的Firefox、Selenium和Geckodriver版本: https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html

DebanjanB
Reply   •   6 楼
DebanjanB    7 年前

此错误消息…

selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process

…意味着 壁虎司机 无法启动/生成新的 网络浏览会话 即 火狐浏览器 会话。

你的主要问题是 不相容 在您使用的二进制文件版本之间,如下所示:

  • 你的 壁虎司机 版本是 0.22.0 .
  • 发行说明 壁虎河V0.21.0(2018-06-15) 明确提到以下内容:

    • Firefox 57(及更高版本)

    • 硒3.11(及以上)

  • 你的 火狐 版本是 52.9 .

所以很明显 壁虎河V0.22.0 以及 Firefox浏览器V57


解决方案

  • 升级 壁虎司机 到 GeckoDriver v0.22.0 水平。
  • 壁虎在指定的位置。
  • Geckodriver对 非根 用户。
  • 升级 火狐 版本到 火狐V62.0.2 水平。
  • 干净的 你的 工程工作区 通过你 集成电路设备 和 重建 仅具有所需依赖项的项目。
  • 如果你的基地 网络客户端 版本太旧,请通过卸载 Revo Uninstaller 并安装最新的GA和发布版本的 网络客户端 .
  • 执行你的 硒试验 作为一个 非根用户 .

GeckoDriver , Selenium and Firefox Browser compatibility chart

supported_platforms_geckodriver_24