使用硒加载铬扩展 [英] Load chrome extension using selenium

查看:124
本文介绍了使用硒加载铬扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要的只是从网上商店加载一个Chrome扩展。
我做了大量的搜索工作,但只知道我们可以从本地机器加载扩展。
我真的怀疑selenium是否没有从网上商店或网址加载扩展的功能。



请让我知道我是什么尝试是否可以使用硒?

解决方案

我不确定为什么你特别从Webstore下载然后安装进入Chrome浏览器。



我发现了一些下载Chrome扩展程序的步骤:

- 连接到互联网的计算机,请从扩展程序页面安装扩展程序: https://chrome.google.com/webstore/detail/

- 浏览扩展源代码。在XP中可以找到:C:\ Documents and Settings \\ Local Settings \Application Data\Google\Chrome\User Data\Default\Extensions\

- 你应该看到一个版本文件夹(即0.0.21_0)。复制此文件夹并将其移动到要安装的计算机上。

- 在已断开连接的计算机上打开chrome并转到Wrench - > Tools - > Extensions

- 点击+开发者模式旁边显示开发人员选项

- 点击'打包扩展...'并选择版本文件夹作为根目录。将私钥文件留空。这将在版本文件夹中创建一个.crx文件以及一个私钥,就像您是开发人员一样。



- 或 -

1-找到您感兴趣的扩展程序的ID。在扩展的详细信息页面上,它将如下所示:
bfbmjmiodbnnpllbbbfblcplfjjepjdn

之后 https://chrome.google.com/webstore/detail/



2-将其粘贴到任何其他浏览器(而非Chrome)中:
https:/ /clients2.google.com/service/update2/crx?response=redirect&x=id%3D~~~~%26uc



<3>和用扩展名ID替换~~~~。
系统会提示您保存CRX文件。将此文件拖到Chrome窗口并继续安装。



来源: https://productforums.google.com/forum/#!topic/chrome/g02KlhK12fU



最后,使用ChromeOptions中下载的.crx文件来加载扩展程序。

  ChromeOptions options = new ChromeOptions(); 
options.addExtensions(new File(/ path / to / extension.crx));
DesiredCapabilities功能=新的DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY,options);
ChromeDriver驱动程序=新的C​​hromeDriver(功能);

资料来源: https://sites.google.com/a/chromium.org/chromedriver/extensions


All I want is to load a chrome extension from web store. I do a lot of search to figure it out, but only got to know we can load extension from local machine. I really wonder if selenium does not have the functionality to load extension from web store or from a URL.

Please let me know what I am trying is possible using selenium ?

解决方案

I am not sure why you are particular about downloading from Webstore and then install into Chrome.

I found some steps to download chrome extensions:

-With a computer connected to the internet, install the extension from the extension page: https://chrome.google.com/webstore/detail/
-Navigate to the extension source code. In XP this is found at: C:\Documents and Settings\\Local Settings\Application Data\Google\Chrome\User Data\Default\Extensions\
-You should see a version folder (ie. "0.0.21_0"). Copy this folder and move it on the machine you want to install on.
-Open up chrome on the disconnected machine and go to Wrench -> Tools -> Extensions
-Click the + next to Developer mode to display the developer options
-Click 'Pack extension...' and choose the version folder as the root directory. Leave the private key file blank. This will create a .crx file in the version folder along with a private key as if you were the developer.

--Or--

1- Find the ID of the extension you’re interested in. When on the details page of the extension, it will be something like : bfbmjmiodbnnpllbbbfblcplfjjepjdn after https://chrome.google.com/webstore/detail/

2- Paste this into any other browser (not Chrome): https://clients2.google.com/service/update2/crx?response=redirect&x=id%3D~~~~%26uc

3- and replacing ~~~~ with the extension ID. You’ll be prompted to save a CRX file. Drag this file to a Chrome window and proceed with installation.

Source: https://productforums.google.com/forum/#!topic/chrome/g02KlhK12fU

Finally, use the downloaded .crx file in ChromeOptions to load the extension

ChromeOptions options = new ChromeOptions();
options.addExtensions(new File("/path/to/extension.crx"));
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
ChromeDriver driver = new ChromeDriver(capabilities);

Source: https://sites.google.com/a/chromium.org/chromedriver/extensions

这篇关于使用硒加载铬扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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