草庐IT

python - 类型错误 : urlopen() got multiple values for keyword argument 'body' while executing tests through Selenium and Python on Kubuntu 14. 04

coder 2023-08-23 原文

我正在尝试在 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
pip install --upgrade --ignore-installed urllib3

关于python - 类型错误 : urlopen() got multiple values for keyword argument 'body' while executing tests through Selenium and Python on Kubuntu 14. 04,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51686224/

有关python - 类型错误 : urlopen() got multiple values for keyword argument 'body' while executing tests through Selenium and Python on Kubuntu 14. 04的更多相关文章

随机推荐