【问题标题】:How to debug functional testing with intern js如何使用实习生 js 调试功能测试
【发布时间】:2014-10-04 10:55:41
【问题描述】:

我是功能测试和实习生的新手。任何人都可以帮助我对需要身份验证的网页进行功能测试,即会话后面的网页。我已经安装了 selenium 网络驱动程序并且能够测试登录页面和一些静态页面没有任何问题。

例如/myproj/login 是登录页面。我能够测试它。现在,当我尝试测试 /myproj/home/index 时,浏览器正在重定向到登录页面。我想测试这个页面应该是什么步骤?一些代码 sn-p 真的会让事情变得清晰。

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!!!');

                });
        }


    });

提前致谢

马尼什

【问题讨论】:

    标签: testing web selenium-webdriver functional-testing intern


    【解决方案1】:

    一种可能性是使用不需要您登录的测试服务器。

    另一种选择是在功能测试中登录您的网站。在登录页面填写用户名和密码(或您用来登录的任何内容)并提交:

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

    然后等待您感兴趣的页面完全加载并继续测试:

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

    如果登录过程很慢,您可能需要使用this.async 增加测试超时时间。

    【讨论】:

    • 感谢您的回复,虽然我无法完成。你能告诉我在哪里可以打印调试消息的输出吗?如果我执行 console.log 它不会向控制台输出任何内容。如果你能指出一些我可以看到调试实习生 js 的链接,那就太好了。
    • 要在命令链中执行 console.log,您必须使用 then 块,例如 .then(function () { console.log("something"); })。至于调试实习生测试,sitepen.com/blog/2014/05/23/how-can-i-debug-intern-tests 有一篇非常详细的博文。
    【解决方案2】:

    面向 Intellij 用户的实习生 JS 调试功能测试:

    以如下目录结构为例。

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

    为节点应用程序设置新的调试配置。

    设置调试配置后,您可以继续调试功能测试。只需在 JS 文件中设置断点并点击调试按钮即可。

    【讨论】:

      猜你喜欢
      • 2015-12-30
      • 2015-08-28
      • 2014-05-21
      • 2015-06-18
      • 2016-02-11
      • 1970-01-01
      • 1970-01-01
      • 2015-10-13
      • 1970-01-01
      相关资源
      最近更新 更多