2016-06-20 25 views
1

所以我用这段代码如何做基本的跨页测试?登录例如

describe('Testing the login page', function (t) { 
    t.it('Should be possible to login', function (t) { 
     t.chain(
      { 
       waitForCQ : '>> textfield[itemId=login]' 
      }, 
      { 
       action : 'type', 
       target : '>> textfield[itemId=login]', 
       text : 'accountname' 
      }, 
      { 
       action : 'type', 
       target : '>> textfield[itemId=password]', 
       text : 'passwd[ENTER]' 
      } 
     ) 
    }) 
}); 

测试我的登录页面与此harness.start()CONF:

harness.start(
    '010_sanity.t.js', 
    { 
    group : 'Login/Logout', 
    items : [ 
     { 
     enablePageRedirect : true, 
     pageUrl : "https://mywebsite.com/Login", 
     url  : "020_login.t.js" 
     }, 
     { 
     enablePageRedirect : true, 
     pageUrl : "https://mywebsite.com/", 
     url  : "021_logout.t.js" 
     } 
    ] 
    }, 
    ... 
); 

而且我现在面临的一个问题。即使将enablePageRedirect选项设置为true,测试似乎也不会从第一页持续到下一页。 相反,在午睡测试界面(中间一个)的日志记录区域,我发现当页面发生变化时,测试将从头开始重新开始。 随着永不止息的微调。

如何做这样一个简单的与午睡的跨页测试? 的文档并没有真的帮了我:提前http://www.bryntum.com/docs/siesta/#!/guide/cross_page_testing

感谢

回答

1

每个测试预计从一个新的一页开始,是自包含的,所以你的每个测试都需要通过登录到开始新鲜的应用程序。启用页面重定向只是意味着一旦登录发生,应用程序可以在到达下一页后继续进行测试。下面是我们如何在测试中编写它的一个例子:

test.chain(
    // Enter username 
    { 
     action: 'type', 
     target: '#user_id', 
     text: 'ACCOUNTNAMEHERE' 
    }, 
    // Enter password 
    { 
     action: 'type', 
     target: '#password', 
     text: 'PASSWORDHERE' 
    }, 
    // Set up detection of the page changing. 
    // The trigger specifies what action will cause the 
    // page to change. The timeout is the maximum length 
    // to wait for the navigation to occur. 
    { 
     waitFor: 'PageLoad', 
     timeout: 20000, 
     trigger: { 
     click: 'input[type=submit]' 
     } 
    } 
);