4

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

enter image description here

6 Answers 6

6

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() 

References

You can find the relevant documentation in:

You can find a couple of relevant discussions in:

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks DebanjanB, this indeed add extension in the chrome but is disabled. is there any any that browser open with enabled extension? or what would be the best way to enable extension so that this may be used.
@user3121891 What exactly do you men by but is disabled, check the documentation I have added within my answer for your reference.
I mean extension is not activated. I want that when chromedriver is launched, it launches with extension already activated
1

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

Comments

0

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

5 Comments

Thanks Prany for your help. Im trying to find the CRX of Browsec or any good VPN plugin but no success yet. The app on the link crxextractor.com doesn't show any crx when i try to add file with extension id in it. In fact, there is no .CRX file in the folder of extension id. Can you help how i can find crx of any good VPN plugin
OK i extracted .crx file. Now can you please confirm if above code is for python 3? as it is showing error
@user3121891 - Have you added this at the top - 'from selenium.webdriver.chrome.options import Options' and 'from selenium.webdriver.common.desired_capabilities import DesiredCapabilities'
I think the script you shared is for java, Im looking for Pyhton
Prany. This is not correct syntax for python 3 as i get a lot of syntax errors on running this code
0

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')

2 Comments

(In actuality, the correct answer is what I stated above - all this person needs to do is include the sub-folder name the extension path)....
0

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:

  1. Go to extensions and check the extension ID (this will be the extension dir)

  2. Now inside your chrome dir locate the "Profile" which has the extension.

  3. Go to the extensions dir and copy the folder with name equal to our Extension ID

  4. Paste the dir inside chrome-win64 binary folder (i am using windows).

  5. 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}") 

Comments

-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) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.