Search code examples
selenium-webdriverwebautomationundetected-chromedriverseleniumbase

Trying to use extension in seleniumbase


I'm trying to use some extensions while automating the browser with seleniumbase.

    with SB(uc=True,browser='chrome',headed=True,extension_zip='path/to/extension') as sb:
        sb.set_window_rect(pos_x,pos_y,500,720)
        sb.open('https://google.com')
        sleep(1000)

But there is no extension running when the task perform. Using command method work expectedly:

pytest test.py --extension-zip=path/to/extension --headed

Since i cannot find the right way to use the extension_zip in python, can someone show me the way to work with it. Thanks.


Solution

  • as mentioned in https://github.com/seleniumbase/SeleniumBase/issues/1817#issuecomment-1480062929, you need to convert your .crx file to a .zip file, and then unzip the file to a folder. Then use extension_dir=DIR as an option. UC Mode uses undetected-chromedriver, which doesn't support zipped/CRX extensions.