如何使用nightwatch.js下载文件xml?

时间:2016-05-06 18:40:34

标签: selenium nightwatch.js

我需要下载一个文件xml但是在下载的那一刻我得到了警告信息"这种类型的文件可能会损害你的计算机(chrome)"

 module.exports = { 
    "download" : function (browser) { 
        browser
            .waitForElementVisible('body',1000)
            .setValue('input[type=text]', 'user') 
            .setValue('input[type=password]', 'password') 
            .click('input[type=submit]') //inicia sesion
            .waitForElementVisible('body',1000)
            .click('[value=RdoTipoBus]') //selecciona radio 
            .click('input[type=submit]') 
            .waitForElementVisible('body',1000)
            .pause(1000)
            .moveToElement('[value=RdoFechas]',10,10) 
            .mouseButtonClick(1)
            .pause(1000)
            .click('div[style="width: 55px;"]')
            .waitForElementVisible('a[href="#5"]',1000)
            .click('a[href="#5"]')              
            .click('input[type=submit]')
            .pause(3000)
            .waitForElementVisible('#masivapg0', 50000 , function(){

                .click("#masivapg0 > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child("+ i +") > td:nth-child(1) > div:nth-child(1) > img:nth-child(4)")          
                /////button download file//

            })  
    }

};

1 个答案:

答案 0 :(得分:0)

查看https://github.com/nightwatchjs/nightwatch/wiki/Chrome-Setup#command-line-switcheshttp://peter.sh/experiments/chromium-command-line-switches/#safebrowsing-disable-download-protection

有一个选项可以使用chromedriver禁用警告,因此在desiredcapabilities对象中您需要类似

的内容
"desiredCapabilities" : {
  "browserName" : "chrome",
  "javascriptEnabled" : true,
  "acceptSslCerts" : true,
  "chromeOptions" : {
    "args" : ["safebrowsing-disable-download-protection"]
  }
}

请注意我还没有测试过这个,但我希望它有所帮助。