我在chrome中添加了一个插件但是,如何通过webdriver
访问它File addonpath = new File("path of .crx file");
ChromeOptions chrome = new ChromeOptions();
chrome.addExtensions(addonpath);
WebDriver driver = new ChromeDriver(chrome );
答案 0 :(得分:-1)
嗨,请按以下方式进行操作
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 **网址的高级REST客户端示例: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&GT。下载此扩展 https://chrome.google.com/webstore/detail/chrome-extension-source-v/jifpbeccnghkjeaalbbjmodiffmgedin
B个。安装它(在Chrome浏览器的右上角会出现一个CRX按钮)
c取代。现在在 chrome web Store 中搜索高级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/
这里将显示所有已安装的添加/扩展
第4步:
please check the Developer option
现在可以看到包扩展的选项
第5步: 单击“包扩展”并在“扩展根目录”下:(第一个选项)粘贴 manifest.json 文件的位置。
希望这能解决您的问题。