Failed to wait for extension background page to load chrome-extension. Can't disable the extension

Viewed 698

I use an extension for my selenium tests with chromedriver, but sometimes I need to disable (or remove) the extension from chrome options and launch chromedriver without any extensions.

So, I try to implement the following experimental logic, where I create an extension and immediately disable it:

    @BeforeSuite(alwaysRun = true)
    public void initCapabilities() {
        getOptions().addExtensions("path/to/file");
        //getOptions().addArguments("--disable-extensions");//1
        System.setProperty("webdriver.chrome.driver", "path/to/driver");
        new ChromeDriver(getOptions());
    }

...................

    private ChromeOptions options = new ChromeOptions();
    protected ChromeOptions getOptions() {
        return options;
    }

All works well, but when I add line (1), the browser launches without extension and the project immediately fails:

> org.openqa.selenium.WebDriverException: unknown error: failed to wait
> for extension background page to load:
> chrome-extension://lkpgdponleanlidigfljoenpapabebon/background.html
> from unknown error: page could not be found:
> chrome-extension://lkpgdponleanlidigfljoenpapabebon/background.html
> Build info: version: '3.141.59', revision: 'e82be7d358', time:
> '2018-11-14T08:17:03'

Also, I tried to use other ways for extension disabling, but all of them doesn't effective - browser opens with extension:

    getOptions().setExperimentalOption("useAutomationExtension", false);
    getOptions().setCapability("chrome.switches", new String[]{"--disable-extensions"});
    getOptions().setCapability("chrome.switches", "--disable-extensions");

How to correctly disable/delete the extension from chromeoptions? Possible exist any other way?

0 Answers
Related