Update to webdriverJS 2.45
This is currently blocked by tests timing out.
Is it mocha-related tests that are timing out? My change to webdriver: https://github.com/SeleniumHQ/selenium/commit/9dbf2e8e771c52f8d18594cf5694f9b60ef05734 might be a culprit. (Basically, the webdriver mocha wrappers now honor the pass-a-done-callback async invocation method, so if any functions being run by mocha take a parameter that isn't a done callback you'll hit a timeout.)
Minimum case I've reproduced so far:
it('shows minimal test case which fails with 2.45', function() {
expect(element(by.binding('greeting'))).toBeDefined();
});
I think this is because of how Jasminewd2 wraps Jasmine compare functions.
@tullmann so far I've only seen problems with the Jasmine tests, but I will test mocha more thoroughly and get back to you.
Here's a more clear minimal case:
fit('shows minimal case without expectations', function() {
element(by.binding('greeting')).then(function(elem) {
console.log('got here OK'); // This works OK
});
protractor.promise.when(element(by.binding('greeting'))).then(function() {
console.log('here here OK 2'); // THIS NEVER HAPPENS, it just stalls.
});
});
We're getting stuck in a loop between ElementFinder.then and ElementArrayFinder.then
It seems like there is some confusion, so I'd like to clarify.
Protractor uses the Selenium Server to help manage and connect browser drivers. This has just been released at 2.45, and the new version fixes the firefox 35/36 issues. The master branch of Protractor has been upgraded to use Selenium Server @2.45 and this will be pushed in a release soon.
Protractor also uses WebDriverJS (the selenium-webdriver node package). This has also just been released at 2.45, but we are having issues upgrading Protractor, which is what this issue is about. Until those issues are resolved, we will remain at WebDriverJS @2.44.0
ETA for the next release?
@BrodaNoel The release with Selenium Server @2.45 is now available (1.8.0)
I am still working on a fix for this issue - things have been slow due to ng-conf :)
@juliemr, so, running the test suite with Firefox 36 should be working well. Right?
Copying from issue https://github.com/angular/protractor/issues/1734:
"More clarifications - FireFox 35/36 will still hang if you are using directConnect, due to #1872. All other forms of connection should work. I'm re-opening this issue due to this lingering problem.
Sorry for the confusion."
Even more minimal error case:
element(by.binding('greeting')).then();
I think we've got a bit of a fundamental problem with our setup where ElementFinder.prototype.then resolves to an ElementFinder, so it won't fully resolve. I haven't yet pinpointed the exact change made to webdriverJS which causes this (EDIT: see promise.Promise.prototype.invokeThen_ - https://github.com/SeleniumHQ/selenium/blob/master/javascript/webdriver/promise.js#L457) , but I think we have a fundamental issue anyway.
@hankduan as the last person to do a big refactor of elements, do you have any ideas on this one?
Basically, we get into a situation where ElementArrayFinder.prototype.then is being called with ElementFinder.prototype.then the fn callback, and it loops forever
ElementArrayFinder.prototype.then = function(fn, errorFn) {
console.log('[elementarrayfinder] .then fn = ' + fn.toString()); // my added logging
if (this.actionResults_) {
return this.actionResults_.then(fn, errorFn);
} else {
return this.asElementFinders_().then(fn, errorFn);
}
};
Proposed solution - this involves some breaking changes, so we'd probably want to release as a new major version.
ElementFinder no longer extends promise. It does not have a then function, so element(by.id('foo')).then is undefined. However, when an action is taken, the element finder is given a then function. For example, element(by.id('foo')).getText().then is defined and resolves to the text of the element.
element.all(by.css('div')) still has a then function - it returns an array of ElementFinders, as it does now.
I believe this solves all the issues with promises resolving to themselves, and improves clarity overall. We need to work out what happens when you use an ElementFinder inside a webdriver function that expects a WebElement, such as browser.actions().dragAndDrop. (EDIT: it just works)
I've made a proof of concept PR: https://github.com/angular/protractor/pull/1926
We have now implemented the proposed solution above, and it will be out in the next release. Because there's the potential to break a lot of tests which relied on element(by.foo).then, we're going to call it v2.0.0, but there is no change in functionality.
Done in 2.0.0