So i have a piece of code:
General.helpers.elementContains = function(selector, value) {
return driver.findElement(webdriver.By.css(selector)).getInnerHtml().then(function(contents) {
assert.equal(contents, value);
});
};
I would like to stub out the getInnerHtml function. I have currently stubbed out both the driver.findElement and the webdriver.By.css functions. My driver.findElement function returns a promise which i use the node module sinon-stub-promise.
sinon.stub(driver, 'findElement').returnsPromise();
sinon.stub(webdriver.By, 'css');
However when running the test as i am unsure of how to stub the .getInnerHtml function i get an error:
driver.findElement(...).getInnerHtml is not a function
I have tried changing the driver.findElement to return a getInnerHtml method which is stubbed and returns a value but i cannot seem to crack this one.
sinon.stub(driver.findElement).returns({getInnerHtml: sinon.stub().returns(value)})
Any help would be appreciated.