Disabling flash in Chrome

前端 未结 3 1354
一向
一向 2021-01-06 08:42

One of our internal applications has a flash object on a page. I need to test one of the corner cases when there is no flash plugin available/installed in the browser: n

相关标签:
3条回答
  • 2021-01-06 09:23

    Found it, there is an another switch which tells chrome not to load external plugins at all:

    --disable-plugins-discovery Disable discovering third-party plug-ins. Effectively loading only ones shipped with the browser plus third-party ones as specified by --extra-plugin-dir and --load-plugin switches.

    By combining --disable-internal-flash and --disable-plugins-discovery I've achieved disabling all flash plugins in Chrome.

    0 讨论(0)
  • 2021-01-06 09:30

    To disable Flash Player, type:

    chrome:plugins
    

    Into your URL bar. There you will see a list of all your plugins, including Flash Player. Press the button that says disable and you are good to go!

    0 讨论(0)
  • 2021-01-06 09:42

    chrome://plugins doesn't exist anymore in Chrome 57 and above. Method proposed by alecxe in accepted answer unfortunately doesn't work for me.

    I was able to workaround this issue by turning on mobile emulation on ChromeDriver. Example code for some languages can be found here: https://sites.google.com/a/chromium.org/chromedriver/mobile-emulation

    Example code for java from the above page:

    Map<String, String> mobileEmulation = new HashMap<String, String>();
    mobileEmulation.put("deviceName", "Google Nexus 5");
    
    Map<String, Object> chromeOptions = new HashMap<String, Object>();
    chromeOptions.put("mobileEmulation", mobileEmulation);
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
    WebDriver driver = new ChromeDriver(capabilities);
    

    You can also specify your own screen resolution, pixel ratio and even userAgent.

    Map<String, Object> deviceMetrics = new HashMap<String, Object>();
    deviceMetrics.put("width", 1920);
    deviceMetrics.put("height", 1080);
    deviceMetrics.put("pixelRatio", 1.0);
    
    Map<String, Object> mobileEmulation = new HashMap<String, Object>();
    mobileEmulation.put("deviceMetrics", deviceMetrics);
    mobileEmulation.put("userAgent", "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19");
    
    Map<String, Object> chromeOptions = new HashMap<String, Object>();
    chromeOptions.put("mobileEmulation", mobileEmulation);
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
    WebDriver driver = new ChromeDriver(capabilities);
    

    This will work with RemoteWebDriver also.

    0 讨论(0)
提交回复
热议问题