Ability to run chrome with extensions downloaded by watir-webdriver

I am trying to start chrome using watir-webdriver but with a specific extension loaded. I could not figure out how to do this in ruby. When I run the following code

@browser = Watir::Browser.new(:chrome, :switches => %w[--load-extension="file path of the extension"])

I will get this message: enter image description here

Now what I noticed was strange, this is a double path. I'm not sure where the first half of the path comes from ("... Google \ Chrome \ Application \ 21 ..."). The second half is what I indicated in the code. When I click OK, it will launch the browser (it will wait until I do this), but without the extension loaded. What a strange error in the manafest.json file in this folder location (and no, this is not a problem with the extension) and it looks good to me. I can launch the browser normally (outside of automation) and it will launch extensions. Let me know if you need more information.

+4
source share
1 answer

OK. I understand what the problem is. Now I use this line of code:

 @browser = Watir::Browser.new :chrome, :switches => %w[--load-extension=.../Chrome/User\ Data/Default/Extensions/geelfhphabnejjhdalkjhgipohgpdnoc/0.9.7_0] 

looks like he doesn't like the quotation marks around the path. He took them, and he launched the extension.

+5
source

Source: https://habr.com/ru/post/1436190/


All Articles