I was facing this problem and final found a solution. Even tho I'm using wd instead of selenium-webdriver, I think my solution might be useful for who ever is working on selenium with Node.js.
Basically, I use the generic waitFor together with an asserter to keep trying the click until it success or timeout. And here is the code
usage
browser
.elementById('some-button')
.clickWhenClickable()
methods.js
var wd = require('wd');
var asserters = require('./asserters');
wd.addElementPromiseMethod('clickWhenClickable', function clickWhenClickable (timeout, pollFreq) {
return this.browser.waitFor(asserters.elementHasBeenClicked(this), timeout, pollFreq);
});
asserters.js
var wd = require('wd');
var Asserter = wd.Asserter;
exports.elementHasBeenClicked = function elementHasBeenClicked (el) {
return new Asserter(function hasBeenClicked (browser, cb) {
el.click(function(err) {
cb(null, !err, null);
});
});
};