When trying to assert the result from getText() keep getting errors that indicate getText() is returning an object instead of a string.
I'm quite new to automated testing but my (experienced) colleague is getting the same and we've had a JS dev look at it, who is also baffled.
Using selenium-cucumber-js as a test framework. (this is the only framework we've been able to get working on the client's network).
I added console.log in the test to prove that the text is retrievable, it logs it fine but the assert still fails.
Have also tried all the various suggestions in this question but still cannot get it to work Protractor: element.getText() returns an object and not String
Page Obj:
zeroResults: function () {
return driver.wait(until.elementsLocated(by.css(...)), 10000)
.then(function () {
return driver.findElement(by.css(...))
.getText().then(function (searchOutcome) {
console.log(searchOutcome); //this was just to prove the text can be found
return searchOutcome;
//I have also tried variations on this (e.g. removing the final return)
Step Def:
this.Then(/^I should see text "Zero results found"$/, function () {
var searchOutcome = page.xx.zeroResults();
expect(searchOutcome).to.equal('Zero results found');
Expect test to pass but instead get:
AssertionError: expected { Object (flow_, stack_, ...) } to equal 'Zero results found'
If I change the assert to:
return Promise.resolve(searchOutcome).should.eventually.equal('Zero results found');
I get:
TypeError: Cannot read property 'eventually' of undefined
These are just some of the attempts but all tries have similar results. This is affecting more than one user, has been proven on multiple test cases and using different asserts/expects.
Any help appreciated.