I need to block the random pop up ads so I can practice testing a certain site smoothly.. I've used the AdBlock Extension
This is what I tried:
ChromeOptions opt = new ChromeOptions();
opt.addExtensions(new File("./Extensions/AdBlock.crx"));
WebDriver driver = new ChromeDriver(opt);
I'm still getting the ads. Any suggestions?
Due to a change in Chrome (versions 137+) you can no longer add extensions via the addExtensions
method.
https://github.com/SeleniumHQ/selenium/issues/15788
There is currently a workaround. When starting Chrome, you can pass the argument --disable-features=DisableLoadExtensionCommandLineSwitch
, however this will eventually be removed. In future versions of Selenium, loading extensions will be available via BiDi (see the issue for links).
Note: this will still work if you use Chromium or Chrome-for-Testing.