node.js - Running blocks of code synchronously in NodeJS/Selenium/Mocha -
i'm doing automated testing in nodejs/selenium/mocha , having lots of trouble getting things execute correctly. the following code block tests webpage clicking button , checking if corresponding counter goes 0 1. it('votes item when user clicks button', function(done) { driver.findelements(by.classname('list-group-item list-group-item-action')) .then(function(buttons) { driver.findelements(by.classname('vote-count')) .then(function(counts) { var flag = true counts[0].gettext().then(function(text) { console.log('test') if (text != '0') flag = false }) buttons[0].click() counts[0].gettext().then(function(text) { if (text != '1') flag = false }) expect(flag).to.equal(tru...