所以我用这段代码测试我的登录页面
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
提前致谢
答案 0 :(得分: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]'
}
}
);