问题
使用selenium让chrome浏览器保持原有的登陆状态
采用 option 来设置出现以下问题:
WebDriverException: unknown error: Could not remove old devtools port file. Perhaps the given user-data-dir at C:\Users\lenovo\AppData\Local\Google\Chrome\User Data is still attached to a running Chrome or Chromium process
原因
路径有问题
具体看路径就是打开 chrome://version/
然后把Default这个文件夹可以复制一份来给代码使用,一个User Data只能供一份代码使用,
如果有webdriver在占用这个Default(即有已在运行的Chrome浏览器进程,就会失败)
解决办法
复制一份Default专门给代码用
然后打开网页,手动登陆一次,之后就可以免密登录了