angularjs - Protractor test throws 'element invalid state' exception as soon as I add 'expect' assertion -
i have protractor test passes - until add 'expect' assertion end of it. that, 'invalidelementstateerror: invalid element state'. i'm aware protractor asynchronous, building queue of promises , reason barfs @ assertion - have no idea why.
describe('compose', function() { it('should send message', function() { browser.ignoresynchronization = true; browser.findelement(by.id('compose-link')).click(); browser.sleep(2000); //select recipient var el = element(by.name('input_to')); el.click(); el.sendkeys('a'); //wait server autofill... browser.sleep(500); el.sendkeys(protractor.key.enter); //snip... //keep clicking buttons, filling out fields etc... //end snip //select category el = element(by.id('section-3')).element(by.css('.secret')); el.sendkeys('cl') el = element(by.id('send-now')); el.click(); //wait confirmation message browser.sleep(1000); expect(element(by.id('confirm-sent')).gettext()).toequal('task sent!'); }); });
btw, ignoresynchronization set true because otherwise browser fails sync apparently due server autofill on elements. can turn ignoresync off after fields makes no difference - still need browser.sleep everywhere make test work, leave set true.
if element appearing on click() action of element wait until click() function returns promise , try checking element visible using wait() function. text of element. using wait() function more suitable use sleep(). here's snippet of functionality -
var ele = element(by.id('confirm-sent'); el.click().then(function(){ browser.wait(protractor.expectedconditions.visibilityof(ele), 10000) .then(function(){ expect(ele.gettext()).toequal('task sent!'); }); });
hope helps.
Comments
Post a Comment