javascript - How can i resolve two distinct promises in a protractor test? -
i beginner node.js. have promise downloads file server, parses json object , returns it. promise returns webpage element(). 2 promises have solved 1 after another: first promise returns json object,this work good, promise gets page element. using key json object have test if element contains same text.
code:
var menuitems = element(by.id('menu')).all(by.tagname('li')); it('should contain', function (done) { jsonpromise.then(function () { // work console.log('inside jsonpromise then'); menuitems.then(function () { //------> not step console.log('inside menuitems then'); expect(menuitems.get(0).gettext()).toequal(jsondata.home); done(); }); }); });
with code protractor returns: 1 test, 0 assertions, 0 failures why that? doing wrong?
note: both console command execute
you need put jsonpromise
on protractor
's control flow:
browser.controlflow().await(jsonpromise).then(function (data) { expect(menuitems.first().gettext()).toequal(data.home); });
Comments
Post a Comment