How to select Chrome extensions to enable when using Selenium [duplicate]

隐身守侯 提交于 2019-12-05 11:28:16
Saifur

You can accomplish this using ChromeOptions class or DesiredCapabilities. For that you have to have the .crx file and load that with driver instance.

import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options


executable_path = "path_to_webdriver"
os.environ["webdriver.chrome.driver"] = executable_path

chrome_options = Options()
chrome_options.add_extension('path_to_extension')

driver = webdriver.Chrome(executable_path=executable_path, chrome_options=chrome_options)
driver.get("http://stackoverflow.com")
driver.quit()

Code taken from @alecxe answer here and more details about ChromeOptions and DesiredCapabilities here

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!