2014-10-04 84 views
1

我是新來的功能測試和實習生。任何人都可以幫助我進行需要認證的網頁的功能測試,即會話後面的網頁。我已經安裝了selenium web驅動程序,並且能夠測試登錄頁面和一些靜態頁面,沒有任何問題。如何調試實習生的功能測試js

例如/myproj/login是登錄頁面。我能夠測試它。現在當我試圖測試/myproj/home/index時,瀏覽器重定向到登錄頁面。我想測試這個頁面應該是什麼步驟?一些代碼片段會讓事情變得清晰。

registerSuite({ 
     name: 'demo', 

     'submit form': function() { 
      remote = this.remote; 
      return remote 
       .get(require.toUrl('https://localhost/login')) 
       .findById('username') 
        .click() 
        .type('test') 
       .end() 
       .findById('password') 
        .click() 
        .type('test123') 
       .end() 
       .findByName('submit') 
        .click() 
       .end() 
       .then(pollUntil('return document.getElementById("osp_homepage_metric_selection_bar");', 30000)) 
       .findById('osp_show_help_popup_trigger_parent') 
       .getVisibleText() 
       .then(function(resultText){ 
        assert.equal(resultText, '<i class=" icon-question-sign"></i>','Test Failed!!!'); 
       }); 
     }, 

     'landing page': function() {  
      return remote 
       .setFindTimeout(Infinity) 
       .findById('show_help_popup_trigger_parent') 
       .getVisibleText() 
       .then(function (resultText) { 
        assert.equal(resultText, '<i class=" icon-question-sign"></i>','Test Failed!!!'); 

       }); 
     } 


    }); 

在此先感謝

馬尼什

回答

1

一種可能性是使用不要求你登錄測試服務器。

另一種選擇是在功能測試中登錄到您的網站。在用戶名和密碼填寫(或任何用於登錄)登錄頁面,並提交:

.findById('username') 
.type('bob123') 
.end() 
.findById('password') 
.type('somepassword') 
.end() 
.findById('submit') 
.click() 

然後等待你感興趣的頁面完全加載並繼續進行測試:

.then(pollUntil(...)) 
// continue testing 

如果登錄過程很慢,則可能需要使用this.async來增加測試的超時時間。

+0

感謝您的迴應,但我無法完成它。你能告訴我在哪裏可以打印調試消息的輸出嗎?如果我做console.log它不輸出任何東西到控制檯。如果你可以指向一些鏈接,我可以看到調試實習生js,這將是很好的。 – 2014-10-07 06:59:51

+0

要在命令鏈中執行console.log,必須使用'then'塊,如'.then(function(){console.log(「something」);})'。至於調試實習生測試,在http://www.sitepen.com/blog/2014/05/23/how-can-i-debug-intern-tests/上有一篇非常詳細的博文。 – jason0x43 2014-10-07 11:34:19

1

的IntelliJ用戶實習生JS調試功能測試:

以例如下列目錄結構。

-C 
-root 
    -node_modules 
     -intern 
     -bin 
      intern-runner.js 
    -tests 

爲節點應用程序設置新的調試配置。

enter image description here

設置您的調試配置之後,您可以繼續調試功能測試。只需在你的JS文件中設置一個斷點並點擊調試按鈕即可。

enter image description here