2

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 );
Shanmuga Raj
  • 125
  • 1
  • 2
  • 14

1 Answers1

-2

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 enter image description here

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

enter image description here

Step 5 : Click Pack Extension and under Extension root directory:(First option) paste the location of manifest.json file.enter image description here

Step 6 : if u have followed everything as above u will get this enter image description here

Hope this solves your query.

Rajnish Kumar
  • 2,828
  • 5
  • 25
  • 39
  • I can able in to install @raj but how can i access during test execution – Shanmuga Raj Mar 29 '16 at 07:30
  • Hi please look at the update answer and its working.just follow step by step. – Rajnish Kumar Mar 29 '16 at 11:57
  • This seems to completely miss the OP's (vague) point: how does he "access" an already installed plugin? This seems to be going into laborious detail on how to install, and then obtain the plugin's own URL, which seems to be completely meaningless. You both need to clarify in advance what the requirement is. – Andrew Regan Mar 29 '16 at 22:26
  • @ Andrew Regan what i have tried to tell **1.**how to install a new extension/add-on on google chrome instance with selenium and **2.**then how to access that. And this is what question is "How to access added plugins in webdriver" – Rajnish Kumar Mar 30 '16 at 05:52
  • (1) He already knows how to; (2) Until OP clarifies what he means by "access" it's no good guessing that he wants that particular URL. Hopefully if he edits his post to clarify how he means to "use" the extension, you can tweak your answer to fit. – Andrew Regan Mar 30 '16 at 22:26