【问题标题】:Why does setting Edge profile results in an error in Selenium Python为什么在 Selenium Python 中设置 Edge 配置文件会导致错误
【发布时间】:2021-04-16 21:59:03
【问题描述】:

我正在尝试运行 Whatsapp web 而不每次都扫描 QR 码,因此我传递了 Edge 的配置文件,以便它自动检测上一个会话而无需再次扫描它。 这是我的代码:

import cv2
from selenium import webdriver
from selenium.webdriver.common import keys
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import threading as thread
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
import time
from msedge.selenium_tools import EdgeOptions
from msedge.selenium_tools import Edge


option = EdgeOptions()
option.use_chromium = True
option.add_argument("--headless")
option.add_argument('user-data-dir= C://Users//USERNAME//AppData//Local//Microsoft//Edge SxS//User Data')
driver = webdriver.Edge(executable_path="J://edgedriver_win64//msedgedriver.exe",options = option)

driver.get('https://web.whatsapp.com')
wait = WebDriverWait(driver, 60)

但我收到一个错误:

文件“h:\Huzaifa\Python\Project\OpenCV\Spam1.py”,第 19 行,在 driver = webdriver.Edge(executable_path="J://edgedriver_win64//msedgedriver.exe",options = option) TypeError: init() got an unexpected keyword argument 'options'

我尝试无头运行它,但它不起作用。 任何帮助将不胜感激。谢谢!

【问题讨论】:

  • 你的 selenium 是什么版本
  • 是 3.7.1 但我下载的网络工具是 3.4.1 edge webtools

标签: python selenium automation


【解决方案1】:

这可能是硒版本问题。您使用的 selenium 版本不支持 options 参数。您可以通过启动 Python 控制台来查看您正在使用的 Firefox 对象的文档,并且:

from selenium.webdriver import Firefox
help(Firefox)

【讨论】:

  • 我使用的是基于 microsoft edge chromium 的浏览器,Edge 也能同样工作吗?帮助(微软边缘)
猜你喜欢
  • 2013-08-26
  • 2019-11-15
  • 2021-02-18
  • 2023-03-05
  • 2021-08-05
  • 1970-01-01
  • 2012-08-19
  • 2011-11-22
  • 2015-06-18
相关资源
最近更新 更多