0

I'm trying to implement a simple function that allows to retrieve the text attribute from an element in a synchronous way but I cannot seem to get the wait function working as expected:

webdriver.WebDriver.prototype.getTextSync = function (element, timeout) {
    var text;

    var deferred = webdriver.promise.defer();

    element.getText().then(function (t) {
        console.log('got text = ' + t);
        text = t;
        deferred.fulfill();
    });

    this.wait(deferred.promise, timeout || 1000);

    console.log('return = ' + text);
    return text;
};

when testing the function, I get the following output, suggesting that wait is actually not waiting for the promise to be fulfilled:

return = undefined
got text = <something>
doberkofler
  • 7,694
  • 16
  • 63
  • 104

0 Answers0