无法使用.crx文件加载Python Selenium Chrome扩展设置 [英] Python Selenium Chrome Extension Settings Not Loading Using a .crx File

查看:203
本文介绍了无法使用.crx文件加载Python Selenium Chrome扩展设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Selenium开发Python.

I'm working on Python with Selenium.

我弄清楚了如何使用扩展程序运行Chrome,唯一的缺点是扩展程序具有设置,并且在启动自动Chrome会话时这些设置始终为空白.

I figured out how to run Chrome with an extension, the only downside is that the extension has settings and these are always blank when starting an automated Chrome session.

运行crx文件时,我在哪里或如何保存设置?我尝试查看了扩展文件夹中的所有文件,但未在其中找到我的当前设置.它们可能存储在配置文件中吗?

Where or how do I save settings when running a crx file? I tried looking in all the files within the extension folder but I did not find my currents settings in them.. Are they maybe stored in the profile?

在我用来打开带有扩展名的chrome驱动程序的代码下面.

Below the code I'm using to open the chrome driver with extension.

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


executable_path = "/webdrivers"
os.environ["webdriver.chrome.driver"] = executable_path

chrome_options = Options()
chrome_options.add_extension('/webdrivers/extension_3_1_0_0.crx')

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

我不想每次启动会话时都配置这些设置.我该如何保留这些设置?

I don't want to configure these settings every time I start a sessions. How can I let these settings stick?

提前谢谢!

推荐答案

我已经通过使用chrome驱动程序加载配置文件来自己修复了该问题.

I already fixed it myself by loading the profile with the chrome driver.

options = Options()
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=DIRECTORYTOPROFILEFOLDERWITHINAPPDATA")

案例已关闭.

这篇关于无法使用.crx文件加载Python Selenium Chrome扩展设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆