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

标签 python selenium selenium-webdriver urllib3 urlopen

我正在尝试在 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 Selenium : Finds h1 element but returns empty text string

java - org.openqa.selenium.json.JsonOutput.write(Ljava/lang/Object;Ljava/lang/reflect/Type;) 由于 JsonException : Attempting to close incomplete json stream

python - 返回Python中拟合系数以便在其他语言中使用的最有效方法?

java - 无法获取或设置 sendkeys 命令的参数映射中的值

更改浏览器后 Python Selenium 保留元素

如果实例化 Selenium WebDriver,Java 线程将失败

java - Selenium-Java-Actions 类型错误 : rect is undefined

python - 当我在 Python 中使用 stdout 时,为什么 Powershell 无法显示字符串?

python - ModelForm 的 save 方法中的 Django admin.py : save_model() is not called by model. save()

python - 使用 Python 从网站下载所有 pdf 文件