简体   繁体   中英

Install/Add chrome extension from Chrome Web Store using Selenium

I am developing test automation using Selenium with Java. I would like to install/add extension to chrome instance launched through Selenium. One way to install/add extension is using .crx file as follow.

ChromeOptions options = new ChromeOptions();
options.addExtensions(new File(ext_path));

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);

driver = new ChromeDriver(capabilities);

But I would like to install/add extension from Chrome Web Store. Can anyone please suggest how to achieve this. Thanks.

You can install extension (packed/unpacked) to chrome with options.addExtensions/addArguments as mentioned here:- https://sites.google.com/a/chromium.org/chromedriver/extensions

alternative: Chromedriver every time opens new chrome instance with temporary profile for the execution. To avoid this you can use existing profile with desired chrome extension installed OR you can send commands to already running instance of chrome which has desir d extension installed.

usually, inline/webstore installation of a Chrome extension can't be tested with ChromeDriver / Selenium alone, because of confirmation dialog. you can use platform-specific hacks to click on the button (eg via AutoIt),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM