I test E2E del goniometro sono incoerenti e non funzionano correttamente.Test goniometro incoerente con passaggio/guasto per l'app AngularJS
Sembra che questo potrebbe essere dovuto a JavaScript asincrono, come discusso qui: Protractor : How to wait for page complete after click a button?.
Tuttavia, qui è detto che goniometro Predisporre automaticamente in sequenza/sincrono: https://github.com/angular/protractor/issues/909
mio script di test:
describe('Login', function() {
var ptor;
beforeEach(function() {
browser.get('https://127.0.0.1:8443');
ptor = protractor.getInstance();
element(by.id('splash')).click();
browser.ignoreSynchronization = true; // <-- to proceed beyond splash screen
});
describe('with correct email and password', function() {
beforeEach(function() {
element(by.id('email')).sendKeys('[email protected]');
element(by.id('password')).sendKeys('adminpassword');
element(by.id('loginButton')).click();
});
afterEach(function() {
ptor.findElement(by.id('logout')).then(function(elem) {
elem.click();
});
});
it('does not show alert', function() { // <-- sometimes passes, sometimes fails
expect(browser.isElementPresent(by.css('.alert-danger'))).toBe(false);
});
it('changes route to /admin', function() { // <-- sometimes passes, sometimes fails
expect(browser.getCurrentUrl()).toMatch(/\/admin/);
});
});
});
Nelle due prove di cui sopra, sia entrambi i test passeranno o uno/entrambi i test non riuscirà con questi messaggi:
Failures:
1) Login with correct email and password does not show alert
Message:
NoSuchElementError: no such element
...
==== async task ====
WebDriver.findElement(By.id("logout"))
...
o
Failures:
1) Login with correct email and password changes route to /admin
Message:
NoSuchElementError: no such element
...
==== async task ====
WebDriver.findElement(By.id("logout"))
...
Pensieri/aiuto molto apprezzato.
Stai testando un'app angularjs o un'app non-angularjs? perché aggiungi questo codice "browser.ignoreSynchronization = true"? –
È un'app Angular. So che ptor.ignoreSynchronization = true non dovrebbe essere richiesto, ma per qualche motivo, i test non procedono al clic del pulsante senza questa impostazione. Vedi il commento di Harri Siirak qui: http://stackoverflow.com/questions/19741896/protractor-times-out-waiting-for-sync-with-page-when-using-resource – ozandlb