2016-11-22 24 views
2

在某些nightwatch.js測試中,我使用console.log打印了一些變量值或註釋。我想知道是否有辦法在nightwatch.js報告中打印控制檯的console.log,因爲只有nightwatch命令/斷言可見。 我想要做的是顯示一個包含所有結果的報告,例如當我在控制檯中運行測試時。 預先感謝您如何在nightwatch.js報告中顯示出現在控制檯中的所有輸出

回答

2

大多數命令都有MSG(可選)參數,

this.demoTest = function (browser) { 
      const msg = "We have passed the test" 
      browser.assert.visible(".testElement",msg); 

     }; 

而不是

v Testing if .testElement is visible 

它將打印

v We have passed the test 

x We have passed the test 
+0

在這種情況下,將作爲註釋bu例如'.getAttribute('#register-form> .box div:nth-​​child(6)','textContent',function(name){ if (i == 1){console.log(' - >首先點擊'+ name.value'); ('。subscription-total','textContent',function(kz){console.log(kz.value); }) }這個console.log將取決於name.value和kz.value – Rita

+0

當我想寫評論時,您的答案將有所幫助,但如果我想從門戶網站打印某些名稱/單詞,則不起作用。有沒有Nightwatch.js命令來代替'console.log('msg');'? – Rita

+0

我真的沒有明白你的觀點。 –

相關問題