TypeError:在 Kubuntu 14.04 上通过 Selenium 和 Python 执行测试时,urlopen() 获得了关键字参数“body”的多个值

2024-02-27

我试图在 Kubuntu 14.04 上用 python 运行 selenium。 我尝试使用 chromedriver 或 geckodriver 时收到此错误消息,两者都是相同的错误。

Traceback (most recent call last):
  File "vse.py", line 15, in <module>
    driver = webdriver.Chrome(chrome_options=options, executable_path=r'/root/Desktop/chromedriver')
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py", line 156, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py", line 251, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py", line 318, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/remote_connection.py", line 375, in execute
    return self._request(command_info[0], url, body=data)
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/remote_connection.py", line 397, in _request
    resp = self._conn.request(method, url, body=body, headers=headers)
  File "/usr/lib/python3/dist-packages/urllib3/request.py", line 79, in request
    **urlopen_kw)
  File "/usr/lib/python3/dist-packages/urllib3/request.py", line 142, in request_encode_body
    **urlopen_kw)
TypeError: urlopen() got multiple values for keyword argument 'body'

import time
import mapeamentos as map
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
from random import randint
import datetime
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
driver = webdriver.Chrome(chrome_options=options, executable_path=r'/root/Desktop/chromedriver')
driver.get('http://192.168.1.11:66/webclient/login.html')

此错误在以下情况下触发:

driver = webdriver.Chrome()

我尝试过使用选项、不使用选项、不使用硬编码路径或使用路径。

我不知道发生了什么事。感谢大家。


您可以更新您的urllib3 using

pip install --upgrade --ignore-installed urllib3
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

TypeError:在 Kubuntu 14.04 上通过 Selenium 和 Python 执行测试时,urlopen() 获得了关键字参数“body”的多个值 的相关文章

随机推荐