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, 2019 in Selenium by Harsha
21,235 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 4, 2019 by Rishabh
I used the same code but my chrome extension did not got activated.Kindly suggest how to activate it.
What's the error that you are getting?

Related Questions In Selenium

0 votes
1 answer

Is there a way to get element by XPath using JavaScript in Selenium WebDriver?

You can use the document.evaluate: Evaluates an XPath ...READ MORE

answered Nov 27, 2020 in Selenium by Gitika
• 65,770 points
3,885 views
0 votes
8 answers

How to open a link in new tab of chrome browser using Selenium WebDriver?

This below code works for me in ...READ MORE

answered Dec 14, 2020 in Selenium by Gitika
• 65,770 points
103,120 views
0 votes
2 answers

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,500 points
13,763 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,184 views
0 votes
2 answers

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

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

answered Sep 4, 2020 in Selenium by Sri
• 3,190 points
2,933 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,910 points
7,258 views
0 votes
1 answer
0 votes
2 answers

Is there any way to get the text of a web element using Selenium Webdriver?

use gettext() in java : string lableText = ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
8,507 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP