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