简体   繁体   中英

How to access added plugins in webdriver

I have added a plugin in chrome but, how can i access it through webdriver

File addonpath = new File("path of .crx file");
ChromeOptions chrome = new ChromeOptions();
chrome.addExtensions(addonpath);
WebDriver driver = new ChromeDriver(chrome );

Hi please do it like below

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
} }

Code will be as above but we have to follow Some basic steps :

NOTE : i am talking example of Advanced REST client for ** CHROME** url below : https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo

Step 1 :

 `Please download or if in-case already present go to the extension's manifest.json file` 

if you want to download the add-on on your local drive please follow like this :

a.> download this extension https://chrome.google.com/webstore/detail/chrome-extension-source-v/jifpbeccnghkjeaalbbjmodiffmgedin

b.> install it (on top right hand side of the chrome browser a CRX button will appear)

c.> Now search Advanced REST client in the chrome web Store or simply copy and paste the link in the browser

https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo

d.> Click on the CRX image/button, you will get two options 在此处输入图片说明

Select download as zip (save it at your preferred location).

e.> unzip it

f.> inside unzipped folder you will find manifest.json file

Step 2 :

Copy the location of mainfest.json file 

Step 3 : go to Chrome browser and in the url please type

 chrome://extensions/  

here all installed add on/extensions will be shown

Step 4 :

please check the Developer option

option for Pack Extension will be visible now

在此处输入图片说明

Step 5 : Click Pack Extension and under Extension root directory:(First option) paste the location of manifest.json file. 在此处输入图片说明

Step 6 : if u have followed everything as above u will get this 在此处输入图片说明

Hope this solves your query.

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