使用Selenium从Chrome网上应用店安装/添加Chrome扩展程序 [英] Install/Add chrome extension from Chrome Web Store using Selenium

查看:302
本文介绍了使用Selenium从Chrome网上应用店安装/添加Chrome扩展程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用Selenium和Java进行测试自动化。我想为通过Selenium启动的chrome实例安装/添加扩展。

  ChromeOptions选项=新的ChromeOptions();其中一种安装/添加扩展的方法是使用.crx文件。 
options.addExtensions(new File(ext_path));

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

驱动程序=新的C​​hromeDriver(功能);

但我想从Chrome网上应用店安装/添加扩展程序。任何人都可以请建议如何实现这一点。
Thanks。

解决方案

您可以使用选项安装扩展(打包/解压缩) .addExtensions / addArguments 如下所述: - https:/ /sites.google.com/a/chromium.org/chromedriver/extensions



替代: Chromedriver 每次都会打开新的chrome实例,并使用临时配置文件执行。为避免这种情况,您可以使用现有的配置文件,并安装所需的chrome扩展名,您可以发送命令到已安装了扩展名扩展名的已运行的chrome实例。



通常,单独使用 ChromeDriver / Selenium 无法测试Chrome扩展的内嵌/ webstore安装,因为确认对话框。
,您可以使用特定于平台的黑客点击按钮(例如,通过AutoIt),


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 (e.g. via AutoIt),

这篇关于使用Selenium从Chrome网上应用店安装/添加Chrome扩展程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆