-
-
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
[Cucumber + v5] How to make hooks (afterStep) to run and finish before next step is executed? #4207
Comments
🤦🏼♂️, I totally forgot about the config hooks, 😳, my bad |
According to the docs there is an afterStep hook: https://webdriver.io/docs/configurationfile.html |
@wswebcreation thanks for your reply but as @christian-bromann mentioned, there is an afterStep for cucumber on the wdio configuration file (according to wdio documentation). If you see my code above im actually using the hook and it triggers certain actions after every step but it doesnt wait for the hook to finish running to execute the next step... I already updated my code to be compatible to v5 but the actions seem to be called way too late for what I need. |
This is how it currently designed in wdio, there are no issues with your code. Should we change the behavior? @wswebcreation @christian-bromann |
Yeah, wdio cucumber hooks should run commands synchronously/respect promises like any other hooks too. |
Hello!, sorry to bother! |
As you can see you are welcome to contribute a bug fix. |
Would love to help but actually im not really a good coder, just a QA with the most basic programming knowledge... and actually have no idea how to help with this :( |
No problem. Then we have to wait until someone can tackle this. You will either see a pull request connected here or other communications in this thread. |
In the meantime i applied this workaround for my project:
This is executes commands synchronously/respect promises. Edit: This workaround makes reporters act weird, even the standard wdio reporter is not displaying the right numbers. i:e.- I ran 13 test cases (some passed, some failed) and this is what i got:
|
In that case, would declaring the hook an async function make it not resolve promises? |
I've looked into this to try and find a solution, and I don't think there's a good generic (i.e. working for both sync/async) way to do this for all the hooks defined in the config file. Cucumber itself offers only 4 hooks: All the other hooks are only attached to fire-an-forget events fired by Cucumber. It might be possible to hack around it in sync mode (using browser.call?), but in async mode I don't see a way to make it work properly. If you have ideas on how this could be done, I could put in some time. However in the meantime, I will document our project config file (which is running in async mode) to note that these hooks should not be used, and to use the Cucumber ones instead. |
We have a similar issue, where we run some async code in the |
I think all the cucumber hooks work same way |
Hey guys, here is update.
|
working is in progress, let's proceed conversation in PR #4288 |
Hi,
Using wdio v4 + cucumber i used some afterSteps and know im trying to use the same in v5 + cucumber but it seems not to be running in order.
On my afterStep i have certain validations, i.e. if result.status === failed then i take a screenshot and do some extra steps, the problem is i am able to take the screenshot but im never able to do the extra steps because when the afterStep is executed, the runner is already executing another test case.
This is the code im using on my afterStep for the v5 (updated from v4):
Sometimes it successfully takes the screenshot of the page with the error, but the other steps are never completed since when it gets there, the runner is already executing another test case..
**WebdriverIO version: v5.11.2
**Mode:Selenium Standalone
**If WDIO Testrunner, running sync/async: sync
**Node.js version: v10.16.0
**NPM version: v6.9.0
**Browser name and version: Chrome
**Platform name and version: MacOS
How can i ensure the afterStep is completely executed before the next step is executed?
I have tried using promises but im not sure if i was implementing well, any help?
The text was updated successfully, but these errors were encountered: