Add helper for waiting for evaluated string

This commit is contained in:
Alan Friedman 2016-02-23 18:36:04 -05:00
parent 0a29d92aed
commit c7902a6e29
2 changed files with 12 additions and 5 deletions

View File

@ -75,11 +75,8 @@ describe('Darkwire', () => {
browser.click('span#send-message-btn', done);
});
it('should send message', () => {
browser.tabs.current = 0;
browser.wait('1s', () => {
browser.assert.text('.messageBody', /Hello world/);
});
it('should send message', (done) => {
helpers.zombie.waitFor(browser, '$(".messageBody").text() === "Hello world"', done);
});
});

View File

@ -44,6 +44,16 @@ var helpers = {
return [1,2,3,4];
}
};
},
zombie: {
waitFor: (browser, str, cb) => {
let int = setInterval(() => {
if (browser.evaluate(str)) {
clearInterval(int);
cb();
}
}, 50);
}
}
};