有一个关于如何使用angularjs运行E2E测试的基本文档:http://docs.angularjs.org/guide/dev_guide.e2e-testing
在我的项目中,我将angularjs用于多页Web应用程序。当我单击页面中的链接时,它将打开一个全新的页面。还有一个登录页面,我必须在测试前登录。
我将在我的测试中遵循:
但我在该文档中找不到有关redirect
的任何信息。我该怎么办?
答案 0 :(得分:0)
不要担心测试准备。整个事情发生在一个可以独立生活的iframe中。
因此,如果您点击发生重定向的链接,它仍会重定向。
请注意,在带有角度的e2e测试中没有特殊的设置部分,这意味着一切都是测试,这意味着您的设置阶段也是一个测试。
您可以做的是第一次正确准备设置的测试:
describe('My Whole Test Suite', function () {
it('Should be able to access page', function () {
browser().navigateTo('/whereSetupOccurs');
input('#username').enter('john');
input('#password').enter('psswrd');
// when you click redirection happen anyway
element('#submit').click();
//check that redirection was made properly
expect(browser().location().url()).toContain("/whereIWantedToGoForMyTests");
});
it('Should be able to ...', function () {
// the real tests you wanted here
});
});