2016-06-22 34 views
0

我一直在嘗試使用「量角器茉莉花2截圖記者」,但HTML報告得到我的執行結果的HTML報告和屏幕截圖與內容創建像量角器茉莉花2截圖記者創建報告,但結果爲'0',沒有截圖

報告

摘要

總規格測試:0

總失敗:0

並沒有截圖保存在該位置。 HTML report screenshot here

我的配置文件是如下

var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter'); 
    var reporter = new HtmlScreenshotReporter({ 
    dest: 'target/screenshots', 
    filename: 'my-report.html' 
    }); 
    exports.config = { 

    directConnect: true, 
    //seleniumAddress: 'http://localhost:4444/wd/hub', 
    capabilities: {'browserName': 'chrome'}, 
    framework: 'jasmine', 
    specs: ['Login_spec3.js'], 
    allScriptsTimeout: 180000, 
    getPageTimeout: 180000, 
    jasmineNodeOpts: { 
    defaultTimeoutInterval: 180000 
    }, 

    // Setup the report before any tests start 
    beforeLaunch: function() { 
    return new Promise(function(resolve){ 
    reporter.beforeLaunch(resolve); 
    }); 
    }, 

    // Assign the test reporter to each running instance 
    onPrepare: function() { 
    jasmine.getEnv().addReporter(reporter); 
    afterAll(function(done) { 
     process.nextTick(done); 
    }) 
    }, 
    // Close the report after all tests finish 
    afterLaunch: function(exitCode) { 
     return new Promise(function(resolve){ 
    reporter.afterLaunch(resolve.bind(this, exitCode)); 
    }); 
    }, 
    onPrepare: function() { 
    var width = 1300; 
    var height = 1200; 
    browser.driver.manage().window().setSize(width,height); 
    } 
    }; 

其他詳情如下: [email protected], nodeVersion:4.2.4, npmVersion:12年2月14日, 茉莉:2.4 .1, selenium-webdriver:2.52.0

有人可以建議我任何解決方案嗎?

+0

它沒有找到你的規格,檢查你的規格路徑! –

+0

感謝您的回覆。 「檢查規範的路徑」是什麼意思?你能告訴我什麼應該是文件夾結構? –

+0

用於conf和spec文件的我的文件夾結構是:User/My_folder/npm-global/lib/node_modules/protractor/FFAutomation,在FFAutomation裏面我有我所有的spec文件和conf文件。 「量角器-jasmine2-screenshot-reporter」的文件夾結構是:User/My_folder/node_modules。我的目標文件夾正在FFAutomation文件夾內創建。我需要改變什麼嗎?請建議。 –

回答

1

@Sonal:得到的問題,您使用的是2種onPrepare功能,這是相互矛盾的,只能使用一個,所以修改後的工作配置將是:

var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter'); 
    var reporter = new HtmlScreenshotReporter({ 
    dest: 'target/screenshots' 
, filename: 'my-report.html' 
}); 
exports.config = { 

directConnect: true, //seleniumAddress: 'http://localhost:4444/wd/hub', 
capabilities: { 
    'browserName': 'chrome' 
} 
, framework: 'jasmine' 
, specs: ['spec.js'] 
, allScriptsTimeout: 180000 
, getPageTimeout: 180000 
, jasmineNodeOpts: { 
    defaultTimeoutInterval: 180000 
}, 

// Setup the report before any tests start 
beforeLaunch: function() { 
    return new Promise(function (resolve) { 
     reporter.beforeLaunch(resolve); 
    }); 
}, 

// Close the report after all tests finish 
afterLaunch: function (exitCode) { 
    return new Promise(function (resolve) { 
     reporter.afterLaunch(resolve.bind(this, exitCode)); 
    }); 
} 
, onPrepare: function() { 
    var width = 1300; 
    var height = 1200; 
    browser.driver.manage().window().setSize(width, height); 
    jasmine.getEnv().addReporter(reporter); 
    afterAll(function (done) { 
     process.nextTick(done); 
    }) 
} 
}; 

我在我的系統測試,它是工作完美;)

+0

非常感謝。有效。 –