python谷歌驱动怎么弄_如何在Selenium Webdriver Python 3中使用Chrome配置文件

根据您的问题和您的代码试用,如果您想打开Chrome浏览器会话,则可以使用以下选项:

要使用默认的Chrome配置文件:

from selenium import webdriver

from selenium.webdriver.chrome.options import Options

options = webdriver.ChromeOptions()

options.add_argument("user-data-dir=C:\\Users\\AtechM_03\\AppData\\Local\\Google\\Chrome\\User Data\\Default")

driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', chrome_options=options)

driver.get("https://www.google.co.in")

注意:您的默认Chrome配置文件将包含很多书签,扩展名,主题,Cookie等。Selenium可能无法加载。因此,按照最佳做法,请为@Test创建一个新的Chrome配置文件,并在配置文件中存储/保存/配置所需的数据。

要使用自定义的Chrome配置文件:

from selenium import webdriver

from selenium.webdriver.chrome.options import Options

options = Options()

options.add_argument("user-data-dir=C:\\Users\\AtechM_03\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2")

driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', chrome_options=options)

driver.get("https://www.google.co.in")

在这里,您将找到有关如何通过Python打开Chrome配置文件的详细讨论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值