Reputation: 1857
All my efforts to open chrome browser with Browsec extension enabled are failing. Here is what i tried in last -
# Configure the necessary command-line option.
options = webdriver.ChromeOptions()
options.add_argument(r'--load-
extension=C:\Users\lap0042\AppData\Local\Google\Chrome\User
Data\Default\Extensions\omghfjlpggmjjaagoclmmobgdodcjboh')
# Initalize the driver with the appropriate options.
driver = webdriver.Chrome(chrome_options=options)
driver.get("http://stackoverflow.com")
This results in error "Failed to load extension from . Manifest files is missing or unreadable"
After search for this error I get that Manifest.json file should be renamed to manifest.json.txt but doing this resulted in same error.
Any help will be highly appreciated
Upvotes: 4
Views: 25499
Reputation: 343
May be I am late to the party but this may help other. None of solution above worked for me. I am using different chrome-binary path setting in my python selenium code.
Solution:
Go to extensions and check the extension ID (this will be the extension dir)
Now inside your chrome dir locate the "Profile" which has the extension.
Go to the extensions dir and copy the folder with name equal to our Extension ID
Paste the dir inside chrome-win64 binary folder (i am using windows).
Add this piece of code (eg. ID):
# Add the path to your extension
epath = r"dknlfmjaanfblgfdfebhijalfmhmjjjo\0.4.8_0"
options.add_argument(f"--load-extension={epath}")
Upvotes: 0
Reputation: 311
if i understood correctly you're trying to load a local unpacked extension into selenium
in that case this code should work
options = options()
options.add_argument("--load-extension=" + unpackedExtensionPath)
a better option would be to pack your extension into a crx file
Upvotes: 1
Reputation: 2441
Simplest answer as far as I'm aware - manifest in subfolder of location you've referenced (e.g. 3.28.2_0' or whatever the latest version of extension is...)
This assumes you're using 'options.add_argument('--load-extension=')...
For options.add_extension('reference crx file .crx')
Upvotes: 0
Reputation: 193088
To open chrome browser with any extension you need to use the add_extension()
method through an instance of chrome.options
class and you can use the following solution :
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_extension(r'C:\path\to\extension.crx')
driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()
You can find the relevant documentation in:
You can find a couple of relevant discussions in:
Upvotes: 6
Reputation: 1
For Python you need wright path to manifest.json file
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
path = os.path.dirname(r"C:\temp\mdnleldcmiljblolnjhpnblkcekpdkpa\19.5.1.10_0\manifest.json")
options = Options()
options.add_argument(f"--load-extension={path}")
driver = webdriver.Chrome(options=options)
Upvotes: -1
Reputation: 2133
Use this code to fetch extensions
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
ChromeOptions options = new ChromeOptions();
options.addExtensions(new File("/pathtoChromeextension.crx")); //adding
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
ChromeDriver driver = new ChromeDriver(capabilities);
Use below to get crx file http://crxextractor.com/ from your extension id which is omghfjlpggmjjaagoclmmobgdodcjboh
Upvotes: 0