[RFC] Replacement for Node-Fibers #6702
Replies: 25 comments 62 replies
-
Sad to hear that, but actually this might be opportunity to simplify code base and make single mode to avoid confusing users what mode they should choose. I have been teaching people how to write webdriverio tests mostly using sync mode, and it shows good results for people that does not know how async code works. But i think having typescript + some eslint rule like - no-floating-promises might simplify work with async version. Probably even some IDE plugin might be developed. Workaround might be possible, and even might help for some time to keep sync mode available. But this situation can happen again in future. Shipping with custom version of Nodejs sounds really hard for newcomers, and also will require huge capacity to support mac/win/linux versions. New node features support will be delayed as well. Some kind of babel transpiler that will replace sync code with it is async version also sounds really hard, and potentially might be source of really weird problems that is hard to debug. I vote for async future of webdriverio + codemod if possible. This will require to update a lot of documentation, and implement some sugar to make code lest await covered, like |
Beta Was this translation helpful? Give feedback.
-
Delete sync mode and force people to start new projects with canonical async/await to be on the safe side. |
Beta Was this translation helpful? Give feedback.
-
It will be quite an overhaul, but I agree with gents above. It definitely simplify wdio development itself, since we won't have to support and think of multiple versions. Let's be real. The more we/everyone will pull this train, the heavier it will get later on. |
Beta Was this translation helpful? Give feedback.
-
For the long term I think this would simplify working with WDIO. Developing a library on top of WDIO and having to offer APIs and browser commands that support both async/sync mode and testing both has been a bit of a challenge IMO. This change would make WDIO more like other JS libs and make it more straightforward and less magical at the expense of some extra bit of verbosity. +1 for this change. |
Beta Was this translation helpful? Give feedback.
-
Suggestions:
|
Beta Was this translation helpful? Give feedback.
-
I'm very much against shipping a custom version of node. Seems like that would be a real maintenance headache and confusing for users as well. But also, I'd be very disappointed to see sync mode go away. Not having to litter the code with |
Beta Was this translation helpful? Give feedback.
-
From what I understand, a babel plugin would manipulate only public APIs, not internal Node/chromium APIs as node-fibers did. Also, a babel plugin would act as an adapter/facade on top of stable, released, pure JavaScript APIs, adding async/await where needed. I don't have much experience with writing transpilers or babel plugins, but this sounds like a more stable solution that is less likely to break with future versions of Node or JavaScript. The biggest advantage I see of WebdriverIO vs other JavaScript test automation frameworks is not having to think about when and where to use async and await, and this reduces the learning curve for manual testers transitioning to writing automation code. What would need to be done to explore the babel option? |
Beta Was this translation helpful? Give feedback.
-
I have been thinking about options how to keep sync mode around while getting rid of Fibers. Here is a possible idea:
Here are some things to consider:
This is an interesting opportunity to do other kinds instrumentation with the test code. Nothing particular pops up in my head just yet but possibilities are endless. Feedback? |
Beta Was this translation helpful? Give feedback.
-
Just updated to node v16 and found this issue, my two cents: Accept the fact that JavaScript is asynchronous, support sync will always require extra effort. Support chaining in async mode, e.g. |
Beta Was this translation helpful? Give feedback.
-
In my opinion, the biggest pain with manually migrating from Ability to chain elements like And for those who are dependant on “non-lazy-initialization” (e.g. when you WANT the element to be not found) an additional parameter can be added |
Beta Was this translation helpful? Give feedback.
-
Hi, I've never used WebdriverIO before this morning, and was looking into async mode. I think we can all agree this is tedious: (await (await $('#foo'))).click(); this is arguably a little better, but it's not immediately clear what style to use and when: await $('#foo').then(foo => foo.click()) I know a lot of people are unfamiliar with (RxJS) observables and/or don't like them much, but you could create operators and instead use // untested
import {from} from 'rxjs';
import {mergeMap, switchMapTo} from 'rxjs/operators';
// operator which gets an element and calls click() on it
const click = observable => observable.pipe(mergeMap(element => element.click());
// creates a new observable from the promise created by $(..)
const findElement = selector => from($(selector));
// clicks on #foo, then clicks on #bar
await (findElement('#foo').pipe(
click,
switchMapTo(findElement('#bar')),
click
)).toPromise(); admittedly, this sort of syntax is a radical departure from the way developers write webdriverIO code--and will have a learning curve, as written. My suggestion, then, for consideration: a new, stream-like or observable-like API. If WebdriverIO can't "fake sync", this could ultimately provide better ergonomics than the current state of the async API. This doesn't need to be RxJS (though it is shedding weight as of v7), but something along those lines. (One potential advantage for WDIO contributors: the "core" API could be written in this manner, and the async API could be provided as it exists now by wrapping observables in promises (see |
Beta Was this translation helpful? Give feedback.
-
I started working on a Babel transform plugin to turn sync code into async one. You can follow the progress here. I am considering renaming browser.url('https://webdriverio')
console.log(browser.window.location.host) // returns "webdriver.io" which will be transformed into: await browser.url('https://webdriverio')
console.log(await browser.execute(() => window.location.host)) // returns "webdriver.io" |
Beta Was this translation helpful? Give feedback.
-
I am not a developer, but I've wrote scripts in other tools, so I am just throwing an idea.
|
Beta Was this translation helpful? Give feedback.
-
Update: $('foobar').click()
$('foobar').$('foobar').$$('foobar')[123].click()
const elem = $('foobar')
elem.dragAndDrop($('barfoo')) into await (await $('foobar')).click();
await (await (await (await $('foobar')).$('foobar')).$$('foobar'))[123].click();
const elem = await $('foobar');
await elem.dragAndDrop(await $('barfoo')); Some issues I see:
|
Beta Was this translation helpful? Give feedback.
-
Update: I now started working towards a simplified async usage where things like this should be possible: await browser.url('https://webdriver.io')
const tagName = await $('foo').$$('bar').get(2).getTagName()
const elem = await $('body').$('header').$$('div').find(
async (elem) => {
const loc = await elem.getLocation()
return loc.x === 30
}
)
console.log((await elem.getLocation()).x) // 30
console.log(await $('foo').$$('bar').length) // 5 So basically all element commands can be chained. When calling |
Beta Was this translation helpful? Give feedback.
-
Hi, first of all, I'd like to thank @christian-bromann and all other guys who are working on Webdriver.IO project, it's been a blast working with the framework :) Now what I want to ask, and this is important to me and my colleagues, how long will I be able to stay with Sync mode and Node v14? Let's just say, that people are still using OG Selenium libraries, which are like 3~ years old (3.141.59), using old Java 1.8 and code is working, so, how long will I be able to use WebdriverIO.io v7, Sync mode and Node v14 for some similar period from this point forward? It's critical for me to know, because lots of my clients, QA trainees and all people involved in QA process are now very dependent and involved with Sync mode and it's a huge part why I chose WebdriverIO (moved from Java and didn't want to use async coding at all). Will actual chromedriver changes affect this and I'll have to move on, update all the projects to async mode and feel some heat and pain? :)) Maybe I'm missing more points here, which I probably do, can anyone help me here with this question? |
Beta Was this translation helpful? Give feedback.
-
Update: I created an initial PR that will help transition from sync to async. As mentioned above we will continue to support sync until we drop support for Node.js v15 which is the last Node.js version that has support for Fibers. Until then people will be able to use sync and async with almost identical syntax. This will also help us build a codemod that will be more reliable. My next steps will be:
Question to all ❓: is there anyone who has a test suite with using async mode already and willing to validate if the new API doesn't break anything? |
Beta Was this translation helpful? Give feedback.
-
Hey all, thank you everyone who chimed in and provided their opinion. This is why I love this project so much! We released |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I recently completed a project on a sizeable nodejs codebase where I converted sync to use async-await using codemods. I'm happy to perform the same for anyone else willing to pay. Feel free to contact me to hear more. ([email protected]) |
Beta Was this translation helpful? Give feedback.
-
In regards to deprecating How pressing is it that we also remove these right away? Is browser.call also deprecated and when would it be removed? Thank you! |
Beta Was this translation helpful? Give feedback.
-
Where is that? The // async call command to replace, e.g.:
const result = await browser.call((async () => { ... })
// can be replaced with
const result = (async () => { ... })()
I think we will remove it in |
Beta Was this translation helpful? Give feedback.
-
What about the REPL? I converted my project from sync to async, but am still using node v14 so that I can use the REPL in sync mode, as I find this the best way to debug. I suppose you could use it in async, but I couldn't quite figure out how to pass the commands properly without any docs, and I am bad at writing async code without any reference. |
Beta Was this translation helpful? Give feedback.
-
I have node version 18 and using wdio lib but failing due to same error: This error is coming for some other service in same repo but e2e test cases repo is working fine. This is my package.json for e2e tests: This is how I am writing tests(just a random vague example): it('Submit functionality', async () => { Still facing the issue. I tried removing wdio/sync but it broke the tests execution in e2e package. |
Beta Was this translation helpful? Give feedback.
-
As mentioned in above comment of mine, I have used the same configuration and my tests are failing due to below error: Timeout of 120000ms exceeded. The execution in the test "Open page and verify page title" took too long. Try to reduce the run time or increase your timeout for test specs (https://webdriver.io/docs/timeouts). I can share one more sample test specs: describe('User Page', () => {
}); |
Beta Was this translation helpful? Give feedback.
-
Unfortunately the day has come where
@wdio/sync
can't continue to be supported anymore due to breaking changes in Chromium. The project was already discontinued and now the author has announced that Node.js v16 can't be supported anymore. The @webdriverio/technical-steering-committee would like to request comments what would be the best way to move forward. I can see a couple of options:@wdio/sync
anymoreAny comments? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions