htmlrgoogle-chromeselenium-webdriverrselenium

How to load extensions using Rselenium


Can anyone give me a hand to figure out how to activate a chrome extension with RSelenium?

Extensions are located in the tab of the browsers, but are not preloaded when using RSelenium.

enter image description here


Solution

  • This is the solution I found.

    1. Convert the extension to a .crx file.

      step a. navigate to chrome://extensions/

      step b. click on "developer mode"

      step c. click on pack extension. Here I assume you already have the extension up and working.

      step d. browse to the folder where the extension was saved. Commonly around this place:

      C:/Users/YOURUSERNAME/AppData/Local/Google/Chrome/User Data/Default/Extensions/ekhagklcjbdpajgpjgmbionohlpdbjgc/5.0.114_0

      step e. click "Pack extension" this will create a .crx file of your extension, which will be placed in the same path as above.

    2. Load the .crx file as part of the preferences for chrome

      #Adjust path accordingly. You can rename the file if you like
      
      PathToCRX="C:/Users/MyExtension.crx" #
      
      cprof <- list(chromeOptions = 
               list(extensions = 
                      list(base64enc::base64encode(PathToCRX))
               ))
      
      
      rD <- rsDriver(port = 4444L,extraCapabilities=cprof, browser ="chrome",chromever = "latest")