I have a issue in my test e2e. I was reading a lot of protractor and selenium and don't find a solution.
My test e2e is :
it('Recorro tabla de MCSS, verificando que existan datos', function () {
browser.sleep(1000);
browser.ignoreSynchronization = true;
logger.info("Recorro tabla de MCSS, verificando que existan datos");
utils.awaitElement(element.all(by.repeater('item in alertsMCSS'))).then(function (rows) {
rows.forEach(function (row) {
row.all(by.tagName('td')).then(function (columns) {
utils.awaitElement(columns[0].getAttribute('innerText')).then(function (instancia) {
logger.info('MCSS: ' + instancia);
expect(instancia !== "");
});
utils.awaitElement(columns[1].getAttribute('innerText')).then(function (valor) {
logger.info('Valor: ' + valor);
expect(valor !== "");
});
});
});
});
browser.ignoreSynchronization = false;
});
The function utils.awaits (I found this function here ) but I don't know if really works or not:
var awaitElement = function (item) {
var EC = protractor.ExpectedConditions;
var ee = item;
browser.wait(EC.presenceOf(ee), 5000);
expect(ee.isPresent()).toBeTruthy();
return ee;
};
When I run the test, sometimes it's all okey, and sometimes the test fails. The description of failure is :
StaleElementReferenceError: stale element reference: element is not attached to the page document
at WebDriverError (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:27:5)
at StaleElementReferenceError (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:227:5)
at Object.checkLegacyResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:505:15)
at parseHttpResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:440:13)
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebElement.getAttribute(innerText)
What's the issue ? How can I resolved?