作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 Chrome 浏览器中有几个自定义配置文件。例如,我想在我的 selenium 中使用“test 2”配置文件。 (见下图)
这是我从互联网上看到的代码。
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = webdriver.ChromeOptions()
options.add_argument(r'user-data-dir=C:\Users\mycomputer\AppData\Local\Google\Chrome\User Data')
browser = webdriver.Chrome(executable_path=r"C:\Users\mycomputer\AppData\Local\Programs\Python\Python36-32\chromedriver.exe", chrome_options=options)
我如何使用“test 2”配置文件?谢谢。
最佳答案
您只需要再添加一个参数:
options.add_argument('--profile-directory=Profile 1')
配置文件 1
- 是您的配置文件的目录,其名称与配置文件名称不同。您可以浏览 user-data-dir
中的所有配置文件目录。如何找出“test 2”配置文件的目录 - 您可以在这里找到 https://superuser.com/a/723145
关于python - 如何在 python 中使用 selenium 中预定义的 chrome 配置文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47901696/
我是一名优秀的程序员,十分优秀!