![](/img/trans.png)
[英]How do I access a dynamically added iframe using Selenium WebDriver?
[英]How to access added plugins in webdriver
我在chrome中添加了一个插件,但是如何通过webdriver访问它
File addonpath = new File("path of .crx file");
ChromeOptions chrome = new ChromeOptions();
chrome.addExtensions(addonpath);
WebDriver driver = new ChromeDriver(chrome );
嗨,请像下面这样
public class ChromeProfileWithAddOn {
public static void main(String[] args) {
// TODO Auto-generated method stub
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
// Add ChromeDriver-specific capabilities through ChromeOptions.
// i have added this add on on chrome = https://chrome.google.com/webstore/detail/pdf-converter/dmgnkfgleaamgbhhojkfijjmjmngokkb
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
########paste the location of .crx file you get in step 6 here########
options.addExtensions(new File("C:\\Users\\###\\Desktop\\hgmloofddffdnphfgcellkdfbfbjeloo.crx"));
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
System.getProperty("webdriver.chrome.driver","D:\\eclipseProject\\###\\src\\com\\###\\chromedriver_win32 (1)\\chromedriver.exe");
ChromeDriver driver = new ChromeDriver(capabilities);
// call chrome driver
driver.navigate().to("chrome-extension://ldlmdngominhfffemgnfpoifladkpple/RestClient.html");
How to get above url :
1.open the mainfest.json file there you will find "local_path":"RestClient.html"
2. make sure your extension is installed in chrome and then
3. go to chrome://extensions/ (follow steps-3 and 4 below)
4. you will get an ID value as shown in the image just below step 4 copy that
5. now u can make your url as "chrome-extension://ID/local_path"
6. now open it in chrome browser
} }
代码将如上所述,但我们必须遵循一些基本步骤:
注意 :我在说以下** CHROME ** URL的高级REST客户端示例: https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo
: https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo
第1步 :
`Please download or if in-case already present go to the extension's manifest.json file`
如果您想将加载项下载到本地驱动器上,请遵循以下步骤:
a。>下载此扩展程序https://chrome.google.com/webstore/detail/chrome-extension-source-v/jifpbeccnghkjeaalbbjmodiffmgedin
b。>安装它(在Chrome浏览器的右上角,将显示一个CRX按钮)
c。>现在在Chrome网上应用店中搜索Advanced REST客户端 ,或者简单地将链接复制并粘贴到浏览器中
https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo
选择以zip格式下载(保存在您的首选位置)。
e。>解压缩
f。>在解压缩的文件夹中,您会找到manifest.json文件
第2步 :
Copy the location of mainfest.json file
第3步:转到Chrome浏览器,然后在网址中输入
chrome://extensions/
此处将显示所有已安装的附件/扩展名
第四步 :
please check the Developer option
Pack Extension的选项现在将可见
步骤5:单击Pack Extension,然后在Extension根目录下:(第一个选项)粘贴manifest.json文件的位置。
希望这可以解决您的查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.