El transportador pasa a la siguiente prueba sin esperar
Estoy usando transportador y cuando ejecuto mis pruebas enpila de navegador Recibo el siguiente error
StaleElementReferenceError: stale element reference: element is not attached to the page document
o dependiendo de lo que haga en elbeforeAll
Error: Index out of bound. Trying to access element at index: 0, but there are only 0 elements that match locator By.cssSelector ...
Aquí está el fragmento de código que causa el error:
describe('...', () => {
it('...', () => {
expect(element.all(by.css(...)).count()).toBe(9);
expect(element.all(by.css('.items').get(0).isDisplayed()).toBeTruthy();
});
}
describe('', () => {
beforeAll((/* done */) => {
element(by.css('.go-home').click(); // .then(done);
//browser.driver.get('/');//.then(done);
});
...
});
Por alguna razón elbeforeAll
continúa y cambia la url, mientras que la anteriorit
todavía se está ejecutando (supongo que en función del error).
Ahora, me las arreglé para hackear esto que funciona. He añadido eldone
alit
como sigue
describe('...', () => {
it('...', (done) => {
expect(element.all(by.css(...).count()).toBe(9);
element.all(by.css(...)).get(0).isDisplayed().then((state) => {
expect(state).toBeTruthy();
done();
});
});
}
describe('', () => {
beforeAll(() => {
element(by.css('.go-home').click(); // works
//browser.driver.get('/'); // still fails
});
...
});
Ahora funciona. Sin embargo si usobrowser.driver.get('/')
falla de nuevo.
Normalmente no tengo que agregardone
para miit
s entonces mi pregunta es: ¿Qué está mal aquí? Cualquier ayuda sería apreciada
ACTUALIZACIÓN: protractor.config.js:
exports.config = {
chromeDriver: '../node_modules/protra...medriver_2.25',
seleniumServerJar: '../node_...-server-standalone-2.53.1.jar',
exclude: [],
specs: [
'../test/e2e/**/*.js'
],
multiCapabilities: [
{
build: 'test',
project: 'ABC',
browserName: 'firefox',
//browserName: 'chrome',
os: 'Windows',
os_version: '10',
directConnect: true
}],
debug: true,
maxSessions: 1,
framework: 'jasmine2',
onPrepare: function () {
browser.driver.manage().window().setSize(1024, 768);
// Register helpers
require('../test/framework/jasmine2');
var disableNgAnimate = function () {
angular
.module('disableNgAnimate', [])
.run(['$animate', function ($animate) {
$animate.enabled(false);
}]);
};
var disableCssAnimate = function () {
angular
.module('disableCssAnimate', [])
.run(function () {
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '* {' +
'-webkit-transition: none !important;' +
'-moz-transition: none !important' +
'-o-transition: none !important' +
'-ms-transition: none !important' +
, 'transition: none !important' +
'}';
document.getElementsByTagName('head')[0].appendChild(style);
});
};
browser.addMockModule('disableNgAnimate', disableNgAnimate);
browser.addMockModule('disableCssAnimate', disableCssAnimate);
}
};