How to extend ExpectedConditions in protractor

Viewed 145

How can protractor.ExpectedConditions be extended in Protractor?

I tried a similar approach to how ElementFinder is extended:

function myFunction(elementFinder){
    function clientScript(e){
        return someCondition(e);
    }
    return () => browser.executeScript(clientScript, elementFinder.getWebElement());
}

protractor.ExpectedConditions.prototype.myFunction = myFunction;

but it fails with:

"E/launcher - Error: TypeError: Cannot set property 'myFunction' of undefined"

I did notice that by assigning protractor.ExpectedConditions.myFunction it seems to work but is that safe to do?

1 Answers

yes its fault in your code, first define this

protractor.ExpectedConditions

then you cant face that error.

Related