How to make permanent settings to chrome driver

筅森魡賤 提交于 2019-12-11 09:36:59

问题


As chrome has blocked Java, Silverlight and other plugins by default now. So to make it work we need to Enable the NPAPI in chrome://flags and restart the browser to make the setting into effect,the same needs to be done in chrome driver however the setting gets lost after restarting the chrome driver, is there any way to make the permanent settings into chrome driver?


回答1:


My earlier comment was wrong because desired capabilities is for non-browser specific settings like proxy address. If you want to modify Chrome behavior, you need to use ChromeOptions. Create Webdriver keyword was created for special cases like this:

*** Settings ***
Library         Selenium2Library

*** Test Cases ***
Stackoverflow
    ${options}=  Evaluate  sys.modules['selenium.webdriver'].ChromeOptions()  sys, selenium.webdriver
    Call Method    ${options}    add_argument      always-authorize-plugins
    Call Method    ${options}    add_argument      enable-npapi
    Create WebDriver  Chrome    chrome_options=${options}
    Go To    https://www.java.com/verify
    Close All Browsers



回答2:


When you open a new instance[profile] of the chrome browser every time, npapi flag can be enabled by using following line:

browser = Watir::Browser.new :chrome,:switches => %w[--enable-npapi]


来源:https://stackoverflow.com/questions/29792197/how-to-make-permanent-settings-to-chrome-driver

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