Skip to content

ES6 Promises and webdriver promises/control flow don't play well together #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sjelin opened this issue Oct 31, 2016 · 1 comment
Closed

Comments

@sjelin
Copy link
Contributor

sjelin commented Oct 31, 2016

Take a look at this test:

var webdriver = require('selenium-webdriver');
var common = require('./common.js');
let flowWrap = (promise: any) => {
  return common.getFakeDriver().controlFlow().execute(() => {
    return promise;
  });
};

describe('mixed promises + control flow', function() {
  let val: number;
  it('should wait for it() to finish', function() {
    val = 1;
    return new Promise((resolve: Function) => {
      resolve(webdriver.promise.fulfilled(7));
    }).then((seven: any) => {
      flowWrap(webdriver.promise.delayed(1000).then(() => {
        val = seven;
      }));
    });
  });

  it('should have waited for setter in previous it()', function() {
    expect(val).toBe(7);
  });
});

This results in the error:

 Expected 1 to be 7.

Meaning that the val = seven line wasn't run (I have verified this in other ways too). You need all three of the following to make this bug happen:

  1. An ES6 promise (or possibly a q promise though I haven't tried)
  2. A webdriver promise
  3. controlFlow.execute() synchronization

It's as though the combination of webdriver and ES6 promises just makes the control flow fall over.

@sjelin
Copy link
Contributor Author

sjelin commented Nov 2, 2016

Closing in favor of SeleniumHQ/selenium#3037

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant