Intern.io单页应用程序功能测试

发帖

我有一个使用Dojo在页面之间导航的单页面应用程序。我正在使用实习生编写一些功能测试,而我试图清除一些小问题。具体来说,我在让实习生超时方面遇到麻烦。超时似乎对我没有任何影响。我正在尝试使用“ setPageLoadTimeout(30000)”设置初始加载超时,但这似乎被忽略了。我也叫“ setImplicitWaitTimeout(10000)”,但是这似乎没有任何作用。

我遇到的主要问题是,在测试环境中,发送请求和解析响应并将其注入DOM可能需要花费几秒钟的时间。我能够解决此问题的唯一方法是,例如,通过显式调用“ sleep(3000)”,但这可能会遇到一些麻烦,有时在我查询它们时DOM元素还没有准备好。(如前所述,setImplicitWaitTimeout(10000)似乎对我没有影响)

使用该应用程序,当DOM更新时,我会触发一个事件。我使用dojo.subscribe来挂接到应用程序中。是否可以在内部使用dojo.subscribe来控制测试的执行?

这是我的代码示例。我还应该提到我使用Dijit,因此在响应返回并创建小部件时(通过data-dojo-type声明)也存在一些延迟...

    define([
    'intern!object',
    'intern/chai!assert',
    'require',
    'intern/node_modules/dojo/topic'
], function (registerSuite, assert, require, topic) {
    registerSuite({
        name: 'Flow1',  
        // login to the application
        'Login': function(remote) {
            return remote
                .setPageLoadTimeout(30000)
                .setImplicitWaitTimeout(10000)
                .get(require.toUrl('https://localhost:8080/'))
                .elementById('username').clickElement().type('user').end()
                .elementById('password').clickElement().type('password').end()
                .elementByCssSelector('submit_button').clickElement().end();
        },
        // check the first page
        'Page1':function() {
            return this.remote
                .setPageLoadTimeout(300000)      // i've tried these calls in various places...
                .setImplicitWaitTimeout(10000)   // i've tried these calls in various places...         
                .title()
                    .then(function (text) {
                        assert.strictEqual(text, 'Page Title');})
                    .end()              
                .active().type('test').end()
                .elementByCssSelector("[title='Click Here for Help']").clickElement().end()             
                .elementById('next_button').clickElement().end()
                .elementByCssSelector("[title='First Name']").clear().type('test').end()
                .elementByCssSelector("[title='Gender']").clear().type('Female').end()
                .elementByCssSelector("[title='Date Of Birth']").type('1/1/1980').end()             
                .elementById('next_button').clickElement().end();
        },
        // check the second page
        'Page2':function() {            
            return this.remote
                .setImplicitWaitTimeout(10000)              
                .sleep(2000) // need to sleep here to wait for request & response injection and DOM parsing etc...
                .source().then(function(source){
                    assert.isTrue(source.indexOf('test') > -1, 'Should contain First Name: "test"');
                    }).end()
                // more tests etc...
        }
    });
});

我正在从内部dojo节点模块中导入相关的Dojo模块,但不确定如何使用它。

谢谢

马丁·G

您的测试正在超时,因为实习生测试的显式超时设置为30秒,无法通过其API访问。可以通过添加'intern/lib/Test'到您的define数组,然后覆盖Test对象的超时来更改它,例如Test.prototype.timeout = 60000;

例如:

define([
    'intern!object',
    'intern/chai!assert',
    'require',
    'intern/node_modules/dojo/topic',
    'intern/lib/Test'
], function (registerSuite, assert, require, topic, Test) {
  Test.prototype.timeout = 60000;
  ...
}

这应该将超时更改为一分钟而不是30s,以防止测试超时。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在Intern中针对Rails提供的骨干应用程序运行功能测试?

来自分类Dev

在Intern功能测试中存储变量

来自分类Dev

如何从Intern功能测试访问全局JavaScript作用域?

来自分类Dev

如何使用Intern在功能测试期间报告JavaScript错误?

来自分类Dev

您如何通过Intern功能测试访问“特殊键”模块?

来自分类Dev

如何使用Intern设置功能测试的超时时间?

来自分类Dev

如何使用intern.io将功能测试名称传递给Sauce Labs

来自分类Dev

java 6调用string intern方法在应用程序启动时是个好主意吗?

来自分类Dev

您如何使用通配符在Intern中指定测试套件?

来自分类Dev

使用Intern测试React 0.5.0网页时双击不触发

来自分类Dev

使用Intern在功能上测试某个元素是否可见(没有元素覆盖)

来自分类Dev

如何使用JMeter测试单页应用程序的客户端性能测试

来自分类Dev

什么是单页应用程序(SPA)?

来自分类Dev

从单页应用程序开始

来自分类Dev

Angular中的单页应用程序

来自分类Dev

使用Django的单页应用程序

来自分类Dev

单页Web应用程序问题

来自分类Dev

jQuery单页移动应用程序

来自分类Dev

单页应用程序angularJS

来自分类Dev

Angular中的单页应用程序

来自分类Dev

单页应用程序中的RedirectToAction

来自分类Dev

单页应用程序架构

来自分类Dev

如何使用赛普拉斯和Auth0测试单页应用程序

来自分类Dev

单页应用程序+ Amazon S3 + Amazon CloudFront + Prerender.io-如何设置?

来自分类Dev

关于单页或多页应用程序的内存问题

来自分类Dev

如何从intern.js测试中加载node.js http模块?

来自分类Dev

越来越有角度和intern.io一起工作

来自分类Dev

越来越多的角度和intern.io一起工作

来自分类Dev

单页应用程序中的引导程序

Related 相关文章

  1. 1

    如何在Intern中针对Rails提供的骨干应用程序运行功能测试?

  2. 2

    在Intern功能测试中存储变量

  3. 3

    如何从Intern功能测试访问全局JavaScript作用域?

  4. 4

    如何使用Intern在功能测试期间报告JavaScript错误?

  5. 5

    您如何通过Intern功能测试访问“特殊键”模块?

  6. 6

    如何使用Intern设置功能测试的超时时间?

  7. 7

    如何使用intern.io将功能测试名称传递给Sauce Labs

  8. 8

    java 6调用string intern方法在应用程序启动时是个好主意吗?

  9. 9

    您如何使用通配符在Intern中指定测试套件?

  10. 10

    使用Intern测试React 0.5.0网页时双击不触发

  11. 11

    使用Intern在功能上测试某个元素是否可见(没有元素覆盖)

  12. 12

    如何使用JMeter测试单页应用程序的客户端性能测试

  13. 13

    什么是单页应用程序(SPA)?

  14. 14

    从单页应用程序开始

  15. 15

    Angular中的单页应用程序

  16. 16

    使用Django的单页应用程序

  17. 17

    单页Web应用程序问题

  18. 18

    jQuery单页移动应用程序

  19. 19

    单页应用程序angularJS

  20. 20

    Angular中的单页应用程序

  21. 21

    单页应用程序中的RedirectToAction

  22. 22

    单页应用程序架构

  23. 23

    如何使用赛普拉斯和Auth0测试单页应用程序

  24. 24

    单页应用程序+ Amazon S3 + Amazon CloudFront + Prerender.io-如何设置?

  25. 25

    关于单页或多页应用程序的内存问题

  26. 26

    如何从intern.js测试中加载node.js http模块?

  27. 27

    越来越有角度和intern.io一起工作

  28. 28

    越来越多的角度和intern.io一起工作

  29. 29

    单页应用程序中的引导程序

热门标签

归档