2014-10-04 27 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

相关问题