-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Deprecate and remove the WebDriverJS promise manager #2969
Comments
@jleyba I am happy to help out with documentation for this. For other people following up: There is some sample code we put on github for reference using Mocha and Async / Await The technical talk we gave at SF Selenium Meetup in Oct 2016 on the move to Async/Await can be found here: Fullstack End-to-end test automation with Node.js, one year later |
…ch can be set to 0 to disable use of the promise manager. Full details and motivation behind this change can be found in #2969
…an issue commands directly, or through a standard promise callback. This is the same pattern used for WebElements with WebDriver.findElement(). Removed Builder.buildAsync() as it was redundant with the change above. This change is part of #2969, to support awaiting the build result: async function demo(url); { let driver = await new Builder().forBrowser('firefox').build(); return driver.get(�url); }
Using the property setter will always take precedence over the environment variable. #2969
Phase 1 is complete: 3.0.0 has been published to npm. |
…romises when the promise manager is disabled. Deprecated promise.when() For #2969
…ise if the promise manager is enabled, otherwise it will return a native promise. For #2969
After the promise manager is removed, how will people be able to call WebDriver functions in NodeJS imperatively (one after another)? |
There's an example of using async/await in the background section of the initial write up for this issue. |
Ok. I tried this, but I still get an error: driver = new webdriver.Builder().forBrowser('chrome').build(); await driver.get(url); driver = await new webdriver.Builder().forBrowser('chrome').build(); has a similar exception await driver.manage().window().maximize(); has a similar exception. process.env.SELENIUM_PROMISE_MANAGER=0; did not stop the errors |
What node version are you using ? |
Also for people jumping on board async await, this thread in the Nodejs project tracks the implementation roll out. |
the selenium driver now returns a promise instead of doing some crazy stack-magic. see this issue for more information: SeleniumHQ/selenium#2969
the selenium driver now returns a promise instead of doing some crazy stack-magic. see this issue for more information: SeleniumHQ/selenium#2969
Since this is a breaking change that impacts almost every line of test code, what is the time line for a complete supported version 4.0 npm module publication? In other words how much time do we have to prepare? |
npm already has |
@jleyba any plan to do another 3.x release? |
@jleyba Thanks! Sorry I was not clear. I need to know when selenium-webdriver will release 4.0. We support multiple languages and we would really prefer to use the same version across all of them. Thus we can't switch to 4.0 alpha, and yet we need a long lead time to prepare for it. I'm only looking for a ballpark figure, "in the next few weeks", "early fall 2018". |
@johnjbarton Simon Stewart (@shs96c) is on record that we’ll be starting the engines on a 4.0 release once the W3C WebDriver Specification goes to Recommendation, which is likely to happen in late May/early June. Expect some beta period, then a full 4.0 release. In other words, “before Christmas” (inside joke for long-time project followers). |
Will we able to use Jasmine after this update implementation ? |
Hello. Thank you in advance. |
@jleyba How we can use async/await for cases when need to fill element (or block of elements) in web page using setter? Example:
Where information is setter with sendKeys, like:
Typescript is not allow async/await for setters. Thank you. |
Does anyone help me with comment above? It is a not good situation, when something couldn't work due to deprecation of functionality. Thanks! |
await mainPage.setInformation("Address information..."); |
@johnjbarton, thank you, but it is not a solution. Its just a method, but the idea to use a setter. |
If TypeScript won't let you use async/await with a setter, don't use a setter. FWIW, I don't think you should try to hide expensive RPCs in a setter anyway. Bit of an anti-pattern IMO. |
@StanislavKharchenko this isn't a TypeScript thing. This is a JavaScript thing. https://es5.github.io/#x11.13.1 The value of a setter expression is always the RHS. So there can be no promise to wait on. |
This is a tracking bug for deprecating and removing the promise manager used by WebDriverJS.
Background
WebDriverJS is an asynchronous API, where every command returns a promise. This can make even the simplest WebDriver scripts very verbose. Consider the canonical "Google search" test:
WebDriverJS uses a promise manager that tracks command execution, allowing tests to be written as if they were using a synchronous API:
The original goal for the promise manager was to make it easier to read and reason about a test's intent. Unfortunately, any benefits on this front come at the cost of increased implementation complexity and reduced debuggability—in the example above, inserting a break point before the first
findElement
call will break before thefindElement
command is scheduled. To break before the command actually executes, you would have to modify the test to break in a callback to thedriver.get()
command:To help with debugging, tests can be written with generators and WebDriver's
promise.consume
function (or equivalent, from libraries like task.js). These libraries are "promise aware": if a generator yields a promise, the library will defer callingnext()
until the promise has resolved (if the promise is rejected, the generator'sthrow()
function will be called with the rejection reason). While users will have to make liberal use of theyield
keyword, they can use this strategy to write "synchronous" tests with predictable breakpoints.The need to use
promise.consume
/task.js will be eliminated in TC39 with the introduction of async functions:Given that the JavaScript language continues to evolve with more support for asynchronous programming (and promises in particular), the benefits to WebDriver's promise manager no longer outweigh the costs. Therefore, we will be deprecating the promise manager and eventually removing it in favor of native language constructs.
Deprecation Plan
Phase 1: allow users to opt-out of the promise manager
Estimated date: now ([email protected])
Within
selenium-webdriver
, replace all hard dependencies on theselenium-webdriver/promise.ControlFlow
class with a new interface:selenium-webdriver/promise.Scheduler
.Add a Scheduler implementation that executes everything immediately using native Promises.
Introduce the
SELENIUM_PROMISE_MANAGER
environment variable. When set to 1,selenium-webdriver
will use the existingControlFlow
scheduler. When set to 0, theSimpleScheduler
will be used.When
SELENIUM_PROMISE_MANAGER=0
, any attempts to use theControlFlow
class will trigger an error. This will help users catch any unexpected direct dependencies. This will also impact the use of thepromise.Deferred
andpromise.Promise
classes, as well as thepromise.fulfilled()
andpromise.rejected()
functions, which all have a hard dependency on the control flow. Users should use the native equivalents.At this point,
SELENIUM_PROMISE_MANAGER
will default to 1, preserving existing functionality.Phase 2: opt-in to the promise manager
Estimated date: October 2017, Node 8.0
Following the release of a Node LTS that contains async functions, change the
SELENIUM_PROMISE_MANAGER
default value to 0. Users must explicitly set this environment variable to continue using the ControlFlow scheduler.Phase 3: removing the promise manager
Estimated date: October 2018, Node 10.0
On the release of the second major Node LTS with async functions, the ControlFlow class and all related code will be removed. The
SELENIUM_PROMISE_MANAGER
environment variable will no longer have any effect.The text was updated successfully, but these errors were encountered: