Protractor: WebElementCondition did not resolve to a WebElement

Created on 5 May 2016  路  7Comments  路  Source: angular/protractor

Running a fresh installation of NPM and receiving this error that is not occurring on my main development box, I have followed all installation steps and cannot reproduce on my main box.
suite is failing with the following error

Failed: WebElementCondition did not resolve to a WebElement: [object Object]
at /Users/corey/.npm-packages/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:698:17

I have identified the error being raised on all of the following commands throughout my suite, and without them the suite passes:
browser.driver.wait(protractor.until.ableToSwitchToFrame(frame))
browser.driver.wait(protractor.until.elementTextIs(element, text))

Most helpful comment

Just to add on to this I was having the same problem with:
browser.driver.wait(protractor.until.elementIsVisible(element(by.css('h1'))));

This line would cause every following expect condition to fail with the same error.

All 7 comments

Just to add on to this I was having the same problem with:
browser.driver.wait(protractor.until.elementIsVisible(element(by.css('h1'))));

This line would cause every following expect condition to fail with the same error.

+1

@coreystinson2 what is the solution for this issue? i am being facing this issue due to this, all my scripts are getting failed.. could you please tell me what is the solution for this....

these are what works for me now
(was very helpful --> http://www.protractortest.org/#/api)

function waitForElement ( _element ) {
    var EC = protractor.ExpectedConditions;
    return browser.wait(EC.presenceOf(_element));
};

function waitForNotElement ( _element ) {
    var EC = protractor.ExpectedConditions;
    return browser.wait(EC.not(EC.presenceOf(_element)));
};

function shouldHaveTextInElement ( _msg, _element, _text, _howLong ) {
    var EC = protractor.ExpectedConditions;
    it(_msg, function() {
        expect(browser.wait(EC.textToBePresentInElement(_element,_text)),_howLong).toBe(true);
    });
};

I should've noted down my solution prior to closing the issue, my apologies.
I believe dropping a version of either selenium or protractor - can't remember which one. These are the specs i'm running with atm and this problem is not occuring.
[email protected]
[email protected]

Hope that helps

i had the same issue.. problem seems to be with selenium-webdriver. Just

replace
protractor.until

with
webdriver.until

Works for me ..Cheers :)

webdriver.until is not a real replacement as it expects an already found WebElement, and not just a WebElementFinder. A better solution is this:

const selector = element(by.css('some-selector'));
browser.wait(protractor.ExpectedConditions.textToBePresentInElement(selector, 'someValue'), 1000)

@juliemr I also stumbled over this issue when upgrading angular to use [email protected]. protractor.until.elementTextIs seems to be broken for protractor. Could you have a look?

Was this page helpful?
0 / 5 - 0 ratings