Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
163 views
in Technique[技术] by (71.8m points)

java - How to install plugin while launch the chrome browser?

I am using selenium,cucumber and java for automation testing.

I have a requirement of installing a plugin to the chrome browser to open my application. This plugin I have already installed. But when I open the chrome browser through selenium this plugin is missing and application is not working.

How to install the plugin each time when the browser is opening?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I'm using Chrome 65.0 and Selenium 3.11.0

Steps :

  1. Run the following URL in Chrome: chrome://version/
  2. Copy the Chrome profile path.
  3. Open the Chrome profile path in Windows Explorer.
  4. Open the Extensions folder (See the date and timestamp, when you installed that extensions)
  5. Copy the folder path.

Code :

public static void main(String[] args){
    System.setProperty("webdriver.chrome.driver", "F:\Automation\chromedriver.exe");
            String pathToExtension = "C:\Users\USER_DELL_2014_07\AppData\Local\Google\Chrome\User Data\Profile 3\Extensions\bhlhnicpbhignbdhedgjhgdocnmhomnp\2.0_0";
            ChromeOptions options = new ChromeOptions();
            options.addArguments("load-extension=" + pathToExtension);
            WebDriver driver = new ChromeDriver(options);
            driver.manage().window().maximize();
          }

That's it! You can use this code and chrome would be instantiated with the given extension

Please let me know if you have any concerns related to this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...