当前有部分端到端测试,输入用户名/密码并单击“登录”。量角器e2e测试登录重定向
它成功,但在“谢谢你已登录”页面结束,而不是重定向到“帐户门户”或“仪表板”,就像通过浏览器登录一样。 \
这个项目的新手,但我们使用OAuth。
主要问题:这听起来像是需要http嘲弄吗?
进一步了解详细:
spec.js
describe('login page', function() {
browser.driver.get('http://url.path/login');
it('should render login page', function() {
// Checking the current url
var currentUrl = browser.driver.getCurrentUrl();
expect(currentUrl).toMatch('/login');
});
it('should sign in', function() {
// Find page elements
var userNameField = browser.driver.findElement(By.id('username'));
var userPassField = browser.driver.findElement(By.id('password'));
var userLoginBtn = browser.driver.findElement(By.id('loginbtn'));
// Fill input fields
userNameField.sendKeys('[email protected]');
userPassField.sendKeys('1234');
// Ensure fields contain what we've entered
expect(userNameField.getAttribute('value')).toEqual('[email protected]');
expect(userPassField.getAttribute('value')).toEqual('1234');
// Click to sign in - waiting for Angular as it is manually bootstrapped.
userLoginBtn.click().then(function() {
browser.waitForAngular();
expect(browser.driver.getCurrentUrl()).toMatch('/success');
}, 10000);
});
});
如果我赶紧点击测试窗口上,我可以看到它成功地达到了“成功”的页面 - 但它不会重定向到仪表板(通过浏览器手动登录时重定向)。我如何继续此测试以保持登录状态并像用户那样访问仪表板?
//项目新增,角度和量角器。
编辑 - 总结这一点:
- 我想量角器开始测试/登录页面上
- 量角器应该找到并填写用户名和密码字段,然后单击登录
- 量角器成功登录,看到一个/谢谢你页面,然后立即重定向到用户的/仪表板 pa ge
- 也许我错过了一个步骤,我们是否需要在量角器测试中手动重定向?
(当用户手动通过浏览器登录时,他们看不到/三江源页 - 。这是一个快速重定向到/仪表板量角器没有达到仪表板页面
当我从你的链接页面上的解决方案运行的代码 - 量角器说:“失败:未定义是不是一个函数”。看起来它在'compareCurrentUrl'函数中失败。我可以在这里找到一个我如何使用函数的示例https://jsfiddle.net/s3tbfkwy/ – bruh