-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Support service launcher in standalone mode #7185
Comments
@conradkirschner services only automatically work when using the wdio testrunner. You can still use services in standalone mode by importing and initialising manually, e.g.: import SauceService from '@wdio/sauce-service'
const browser = await remote({
logLevel: "silent",
capabilities: {
browserName: "chrome"
}
});
const sauceService = new SauceService(sauceOptions)
await sauceService.onPrepare() There is not much documentation which hook method does which things but you can just check out the code to see what is going on and what you need to parse in as arguments. |
I raised that feature request, because I would like to wish to pass launcher services directly to remote(); Background: I integrate currently wdio in backstopJS To avoid to go out of sync later with BackstopJS logic, I would like to make it happen in wdio. On the other Hand I could implement this in a programmatically way, but that would mean I have to rebuild/copy stuff from wdio... (Not sure if that is understandable, maybe that is out of scope for wdio, then implementing it in backstopjs is fine) |
I am not sure how this is suppose to work. In the testrunner scenario we have various of very well defined situations, e.g. before a test starts or after a worker finishes. We have none of that in the standalone world. The only thing that might work is to add support for |
Yeah, I would not go for full support. Partly support for launcher services would be fine, as for most of them calling onPrepare (so when remote() get called?) and complete on remote() close event. How it should work? (Worker Services) Thanks for fast response. |
Ok, I guess it makes sense to enable support for launcher. Some things we need to consider to do:
The problem I see is that currently the last command is Any contributions on this are appreciated. |
I wonder how you are expecting this to work because I too use services in a programmatic way as can be seen here https://github.com/erwinheitzman/jest-webdriverio-standalone-boilerplate and in my case I run the onPrepare method in Jest's globalSetup, however I could have set this up in different ways. Sometimes you want a service to be run once and other times it needs to run multiple times (think of before anything like in my setup, or for example on every remote instance creation). |
very very good input, thanks for that. I would assume that there should be a check if the service is already instantiated, calling it more then once would mean it's "onBefore call". (Kind of a small hook to a "service registry") The onBefore call I would think belongs to the runner, any setup that is required before or with instantiation of remote() should belong to remote(); e.g. I would not start selenium-standalone-server more then once. If I want that, I could still use the programmatically way. // but it's late here maybe I overlooking something, for your case that would mean you could avoid the registry in global scope and use it in test scope, where you be able to choose which launcher per test(file) you want (like some with mock, some without, just with the need of load a different config in your onBefore call (https://github.com/erwinheitzman/jest-webdriverio-standalone-boilerplate/blob/03662074c76f546b87f96fd00f41b2f4897c247b/__tests__/async.ts#L7)) pretty interessted what you think about that idea |
Well that's the problem, there are no hooks like you have in the wdio test runner. The reason you have the before hook and such in the wdio test runner is because we use Mocha/Jasmine/Cucumber's hooks for this. Because WebdriverIO doesn't know anything when running programmatically, you cannot tell it to run before every test just like you would with the test runner. Summary:
Edit: I really appreciate this discussion and I hope this helps to shape a solution for your issue :) |
I started but failed a bit due the fact that browser.deleteSession is not overwritable... In olden Days of JS such things where easy ...
-> This doesn't work I would kindly ask for some help | @erwinheitzman @christian-bromann |
Even in the old days you could prevent these things but it wasn't common back then.
You could technically use Given that @erwinheitzman and me already had concerns bringing this into the core framework I would suggest to go with the way described above. Happy to further assist. |
Is your feature request related to a problem? Please describe.
I want to use wdio programmatically:
await remote();
Here I want to use sauce service.
Describe the solution you'd like
https://webdriver.io/docs/wdio-image-comparison-service/#running-programmatically
I want to use it like this but able to hook the services like in wdio.conf.js
example:
const browser = await remote({
logLevel: "silent",
capabilities: {
browserName: "chrome"
},
services: [['sauce', {sauceOptions}]]
});
Describe alternatives you've considered
Alternative could be a hook or better documentation
The text was updated successfully, but these errors were encountered: