Ability to launch chrome with extensions loaded with watir-webdriver

五迷三道 提交于 2019-12-23 12:45:09

问题


I'm attempting to launch chrome using watir-webdriver but with a specific extension loaded. I haven't been able to 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:

Now what I noticed was odd was the dual path. I'm not sure where the first half of the path is coming from ("...Google\Chrome\Application\21..."). The 2nd half of it is what I specified in the code. When I click OK it'll launch the browser (it will wait until I do) but without the extension loaded. What's odd about the error is the manafest.json file is in that folder location (and no it's not an extension issue) and looks fine to me. I can launch the browser normally (outside of the automation) and it'll run the extensions. Let me know if there's more information that you need.


回答1:


OK I figured out what the problem was. I am now using 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 it doesn't like the quotes around the path. Took those out and it launched the extension fine.



来源:https://stackoverflow.com/questions/12586751/ability-to-launch-chrome-with-extensions-loaded-with-watir-webdriver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!