小编BiT*_*23b的帖子

InvalidArgumentException:消息:无效参数:使用 ChromeDriver Selenium 启动 Chrome 时,用户数据目录已在使用错误

我正在尝试使用默认用户使用 selenium python 库打开网页,脚本使用默认用户至关重要,但如果我的 chrome 浏览器已经打开脚本崩溃并给我这个错误:

selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
Run Code Online (Sandbox Code Playgroud)

我已经尝试了这里给出的所有解决方案:

如果打开另一个 chrome 实例,Selenium chromedriver 将不会启动 URL

Selenium 不会在新选项卡中打开新 URL(Python 和 Chrome)

并阅读旧版 chromedriver 版本中存在错误,但已在 chrome 74(我正在使用)中修复:https : //github.com/SeleniumHQ/docker-selenium/issues/741

from selenium import webdriver
import time
from getpass import getuser

def run():
    # Chrome driver path
    chromedriver = r'C:\Users\user1\Downloads\chromedriver_win32\chromedriver_new.exe'

    # Get chrome webdriver options and set open the browser as headless …
Run Code Online (Sandbox Code Playgroud)

python selenium google-chrome selenium-chromedriver chrome-profile

6
推荐指数
1
解决办法
2192
查看次数