Is there any way to load an extension in chrome browser using Selenium Webdriver?

0 votes
I want to load an extension from my system and open it in chrome browser. How can I do that using Selenium Webdriver?
Jun 3 in Selenium by Harsha
410 views

1 answer to this question.

0 votes

Hey Harsha, you can load an extension in chrome browser using ChromOptions in Selenium Webdriver. You can follow these steps to add a chrome extensions to chromeOptions and then load it while running a browser:

  1. Add "GET CRX" extension from Google Web Store.

  2. Download your extension (in my case its Selenium IDE extension).

  3. Go to Chrome Web Store >> Search for your extension (the one you've already downloaded) >> Click on Get CRX on top-right of the browser >> Click on Get CRX for this Extension. This would download the CRX file.

  4. Now, write your test script by following this code snippet:

    • public class openChromeExtension {
          
          public static String driverPath = "C:\\\\Users\\\\Rishabh\\\\Downloads\\\\chromedriver.exe";
      
          public static void main(String[] args) {
              
              System.setProperty("webdriver.chrome.driver", driverPath);
      
              ChromeOptions options = new ChromeOptions();
              options.addExtensions(new File("C:\\Users\\Rishabh\\Downloads\\Selenium IDE.crx"));
      
              DesiredCapabilities capabilities = new DesiredCapabilities();
              capabilities.setCapability(ChromeOptions.CAPABILITY, options);
              ChromeDriver driver = new ChromeDriver(capabilities);
              
              System.out.println("Opening extension");
              driver.get("chrome-extension://mooikfkahbdckldjjndioackbalphokd/index.html");
      
              driver.navigate().refresh();
              System.out.println("Refresh successfully");
          }
      
      }
answered Jun 3 by Rishabh

Related Questions In Selenium

0 votes
1 answer
0 votes
5 answers
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,430 points
1,190 views
0 votes
1 answer
0 votes
1 answer

What is the role of TestNG & JUnit frameworks in Selenium?

Well TestNG and JUnit are test frameworks ...READ MORE

answered Apr 18, 2018 in Selenium by king_kenny
• 3,650 points
381 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,510 points
1,274 views
0 votes
1 answer
0 votes
1 answer