1
我有用Jasmine写的量角器代码应该登录用户。不幸的是,在转到根网址后需要一段时间(大约5秒)后发生重定向,我无法使量角器等待它。我已经尝试browser.wait
,我试过使用承诺,我试过this blogpost,但没有做到。它仍然不会等待。登录页面是Keycloak服务器的页面,这就是为什么我使用driver.findElement
而不是element
。这是我目前的代码:量角器不会等待重定向
describe('my app', function() {
it('login', function() {
var driver = browser.driver;
browser.get('/');
console.log('get');
driver.findElement(by.id('username')).isPresent().then(function() {
console.log('waited');
driver.findElement(by.id('username')).sendKeys("test");
driver.findElement(by.id('password')).sendKeys("test");
driver.findElement(by.id('kc-login')).click();
driver.findElement(by.css('.page-header')).isPresent().then(function() {
console.log('ok');
expect(browser.getLocationAbsUrl()).toMatch("/test");
});
});
});
});
你知道我能做些什么来使它工作吗?我已经开始量角器项目,这个种子:https://github.com/angular/angular-seed