无法使用Selenium webdriver将解压后的扩展加载到chrome中 [英] Unable to load unpacked extension into chrome using Selenium webdriver
问题描述
我是使用网络驱动程序的新手,但是我已经按照这里提到的方法(我如何使用解压后的扩展程序来启动Chrome?)以及我可以从其他网络搜索中获得的所有内容。
我试图测试我开发的chrome的扩展,但我一直无法弄清楚如何启动扩展加载的chrome。这是我到现在为止,如果有人能告诉我这个问题的代码(我成功地使用webdriver启动Chrome),我将不胜感激:
导入时间
从selenium导入webdriver
从selenium.webdriver.common.desired_capabilities import DesiredCapabilities
browser = webdriver。 Chrome()browser.get('http://seleniumhq.org/')
ChromeOptions options = new ChromeOptions();
options.addArguments(load-extension = C:\Users\mave\Desktop\Browser_Extension_Feature\extension_v5);
DesiredCapabilities功能=新的DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY,options);
ChromeDriver驱动程序=新的ChromeDriver(功能);
time.sleep(15)
browser.quit()
<我终于能够弄清楚如何运行一个解压后的扩展,并将这个代码留给以后任何有类似麻烦的人:
导入时间
$ b $ se from selenium import webdriver
$ b $ se from selenium.webdriver.chrome.options import Options
chrome_options =选项()
chrome_options.add_argument(load-extension = C:\Users\mave\Desktop\Browser_Extension_Feature\extension_v5);
browser = webdriver.Chrome(chrome_options = chrome_options)
browser.get('http://www.seleniumhq.org/')
time.sleep(5)
browser.quit()
I am new to using web driver but I have followed what was mentioned here (How can I launch Chrome with an unpacked extension?) and all that I could get from other web search.
I am trying to test an extension for chrome which I have developed but I haven't been able to figure out how to start chrome with extension loaded on it. Here is what I have till now and I would appreciate if someone could tell me the issue with the code (I was successful in launching Chrome using webdriver):
import time
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
browser = webdriver.Chrome() browser.get('http://seleniumhq.org/')
ChromeOptions options = new ChromeOptions();
options.addArguments("load-extension=C:\Users\mave\Desktop\Browser_Extension_Feature\extension_v5");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
ChromeDriver driver = new ChromeDriver(capabilities);
time.sleep(15)
browser.quit()
I was finally able to figure out how to run an unpacked extension and would leave this code for anyone who has similar troubles in future:
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("load-extension=C:\Users\mave\Desktop\Browser_Extension_Feature\extension_v5");
browser = webdriver.Chrome(chrome_options=chrome_options)
browser.get('http://www.seleniumhq.org/')
time.sleep(5)
browser.quit()
这篇关于无法使用Selenium webdriver将解压后的扩展加载到chrome中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!