【问题标题】:how download a file xml using nightwatch.js?如何使用 nightwatch.js 下载文件 xml?
【发布时间】:2016-05-06 18:40:34
【问题描述】:

我需要下载一个文件 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//

            })  
    }

};

【问题讨论】:

  • 我的回答好运吗?

标签: selenium nightwatch.js


【解决方案1】:

看看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"]
  }
}

请注意,我尚未对此进行测试,但希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多