Python chrome_options=option设置用户自己的数据目录时,driver.get()失效原因之一

from selenium import webdriver
import time

option = webdriver.ChromeOptions()
option.add_argument("--user-data-dir=C:\\Users\\Beck\\AppData\\Local\\Google\\Chrome\\User Data")
#Chrome浏览器网址栏输入:chrome://version/,在个人资料路径后找到
driver = webdriver.Chrome(chrome_options=option)
driver.get("https://www.cnblogs.com")

要事先关闭所有已打开的chrome浏览器!!!
经查阅资料得知,网上也确实有此情况的介绍,
见《Selenium chromedriver hangs if I specify user-data-dir in Chrome options》:

“The only one client could be connected to a debugger in one time. So, to fix the issue, when we want to enter to a user profile using a debugger - to avoid chromedriver hangs trying to connect to the debugger, we must close an existing Chrome session”

翻译为:只有一个客户端可以一次连接到调试器。所以,为了解决这个问题,当我们想要使用调试器进入用户配置文件为了避免chromedriver挂起试图连接到调试器,我们必须关闭一个现有的Chrome会话。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

超周到的程序员

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值