0

For a project of mine I decided to go with Selenium. It's a "scanner" for an web based online game, hence interaction with the page is needed. All things set and done I'm worrying for the security of my application and hence I took a look at well-known questions on SO. I found bunch of suggestions which may help securing the detectability of said programme.

What is left is something related to Chrome Plugins. In my Project File I got the chromedriver.exe and a dedicated resource folder for stuff like the cookies and settings it's supposed to run with. Now I want to run the Chromedriver.exe with Chrome Plugins.

So is there any way to download Chrome Plugins in the Chromedriver.exe and run them every time with the Selenium process?

J. Doe
  • 61
  • 1
  • 2
  • 9

2 Answers2

1

First method is to create a chrome profile and load it with youre chrome plugins

from selenium import webdriver

options = webdriver.ChromeOptions() 
options.add_argument("user-data-dir=C:\\Path") #Path to your chrome profile
w = webdriver.Chrome(executable_path="C:\\Users\\chromedriver.exe", 
chrome_options=options)

Read more here How to load default profile in chrome using Python Selenium Webdriver?

another method is to add it in the chrome options:

options.add_extension('./exampleOfExtensionDownloadedToFolder.crx')
PowerKuz
  • 11
  • 2
0

To download the chrome extension, follow below steps.

  1. add chrome extension.
  2. Go to http://chrome://extensions/]
  3. Enable developer mode.
  4. Click on 'Details' of desired extension.
  5. Click on 'Pack Extension'.
  6. Browse extension root directory. Eg. C:\Users\Admin\AppData\Local\Google\Chrome\User Data\Default\Extensions\mooikfkahbdckldjjndioackbalphokd\3.17.0_0 ( Don't forget to sort the folders by date and select latest folder.)
  7. Click on 'Pack Extension'.( If any error get encountered related to key browse manifest.json file from step 6 path)
  8. Browse to extension path (Eg. C:\Users\Admin\AppData\Local\Google\Chrome\User Data\Default\Extensions\mooikfkahbdckldjjndioackbalphokd ) you will find .crx and .pem file.
  9. Copy and paste both the files in resources folder of your project.

Below java code will help you to access the extension.

System.setProperty("webdriver.chrome.driver",
            System.getProperty("user.dir") + "\\src\\test\\resources\\executables\\chromedriver.exe");
    ChromeOptions options = new ChromeOptions();
    options.addExtensions(new File(System.getProperty("user.dir") + "\\src\\test\\resources\\executables\\5.6_0.crx"));
    options.addArguments("start-maximized");
    WebDriver driver = new ChromeDriver(options);
Dilip Meghwal
  • 632
  • 6
  • 15