第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

量角器e2e測試用例,用于下載pdf文件

量角器e2e測試用例,用于下載pdf文件

慕斯709654 2019-10-11 14:31:26
誰能告訴我如何使用茉莉花框架編寫測試用例以下載pdf文件的鏈接?提前致謝。
查看完整描述

3 回答

?
開滿天機

TA貢獻1786條經(jīng)驗 獲得超13個贊

我需要根據(jù)預期結(jié)果檢查下載文件的內(nèi)容(本例中為CSV導出),并發(fā)現(xiàn)以下內(nèi)容可以正常工作:


var filename = '/tmp/export.csv';

var fs = require('fs');


if (fs.existsSync(filename)) {

    // Make sure the browser doesn't have to rename the download.

    fs.unlinkSync(filename);

}


$('a.download').click();


browser.driver.wait(function() {

    // Wait until the file has been downloaded.

    // We need to wait thus as otherwise protractor has a nasty habit of

    // trying to do any following tests while the file is still being

    // downloaded and hasn't been moved to its final location.

    return fs.existsSync(filename);

}, 30000).then(function() {

    // Do whatever checks you need here.  This is a simple comparison;

    // for a larger file you might want to do calculate the file's MD5

    // hash and see if it matches what you expect.

    expect(fs.readFileSync(filename, { encoding: 'utf8' })).toEqual(

        "A,B,C\r\n"

    );

});

我發(fā)現(xiàn)Leo的配置建議有助于將下載文件保存在可訪問的位置。


30000毫秒的超時是默認值,因此可以省略,但是我提醒您,以防萬一有人要更改它。


查看完整回答
反對 回復 2019-10-11
  • 3 回答
  • 0 關注
  • 475 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號