Skip to content

Cannot add unpacked extension on Ubuntu VPS #2334

Closed
@iamumairayub

Description

@iamumairayub

I am trying to add an extension but script fails to run. When I comment out extension_dir line it works fine, but that is not what I want.

I same script on Windows headed and it works just fine.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from concurrent import futures

from seleniumbase import Driver

def run_session(profile_id):

    try:

        chrome_options = Options()

        chrome_options.add_argument('--headless=new')
        print(chrome_options.to_capabilities())

        driver = Driver(
            cap_string=chrome_options.to_capabilities(),
            uc=True, 
            extension_dir=r'/home/NopeCHA-CAPTCHA-Solver',
        )

        driver.get("http://lumtest.com/myip.json")
        print(driver.page_source)

        return 'finished'

    except:
        return traceback.format_exc()
    

with futures.ThreadPoolExecutor(max_workers=5) as executor:

    all_jobs = []
    for profile_id in (1,2,3):
        job = executor.submit(
            run_session, 
            profile_id,
        )
        all_jobs.append(job)

    for future in futures.as_completed(all_jobs):
        print('Run completed: {}'.format(future.result()))

I get this error when I run above code.

(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed

Tried this, script runs, but no extension is added.

def run_session(profile_id):

    chrome_options = Options()

    chrome_options.add_argument('--headless=new')
    chrome_options.add_argument(r'--load-extension=/home/NopeCHA-CAPTCHA-Solver')

    print(chrome_options.to_capabilities())

    driver = Driver(
        cap_string=chrome_options.to_capabilities(),
        uc=True, 
    )

    driver.get("chrome://extensions/")
    print(driver.page_source)
    driver.save_screenshot('test.png')
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:        20.04
Codename:       focal

python -V
Python 3.10.7

>>> import seleniumbase
>>> seleniumbase.__version__
'4.21.4'

Metadata

Metadata

Assignees

No one assigned

    Labels

    UC Mode / CDP ModeUndetected Chromedriver Mode / CDP Modeinvalid usageYou may need to change what you're doingquestionSomeone is looking for answers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions