How to disable 'This type of file can harm your computer' pop up

后端 未结 8 1682
时光取名叫无心
时光取名叫无心 2020-11-27 20:43

I\'m using selenium chromedriver for automating web application. In my application, I need to download xml files. But when I download xml file, I get \'This type of file can

8条回答
  •  盖世英雄少女心
    2020-11-27 21:29

    The accepted answer stopped working after a recent update of Chrome. Now you need to use the --safebrowsing-disable-extension-blacklist and --safebrowsing-disable-download-protection command-line switches. This is the WebdriverIO config that works for me:

    var driver = require('webdriverio');
    var client = driver.remote({
        desiredCapabilities: {
            browserName: 'chrome',
            chromeOptions: {
                args: [
                    'disable-extensions',
                    'safebrowsing-disable-extension-blacklist',
                    'safebrowsing-disable-download-protection'
                ],
                prefs: {
                    'safebrowsing.enabled': true
                }
            }
        }
    });
    

    Note that I am also disabling extensions, because they generally interfere with automated testing, but this is not strictly needed to fix the problem with downloading XML and JavaScript files.

    I found these switches by reading through this list. You can also see them in the Chromium source.

提交回复
热议问题