Skip to content
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

(docs): saveScreenshot requires afterTest hook to be async #11005

Merged
merged 2 commits into from
Sep 6, 2023

Conversation

hashar
Copy link
Contributor

@hashar hashar commented Aug 24, 2023

Proposed changes

When requesting a screenshot in afterTest I would sometime lack a screenshot file. I eventually found browser.saveScreenshot is async and the hook has to be explicitly defined async: #5545 (comment)

Add an example for using browser.saveScreenshot in the afterTest hook with the hook being set async explicitly. This would have saved me a bit of troubleshooting time.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Further comments

Reviewers: @webdriverio/project-committers

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 24, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: hashar / name: Antoine Musso (f7cabb6)
  • ✅ login: christian-bromann / name: Christian Bromann (0425383)

@hashar
Copy link
Contributor Author

hashar commented Aug 24, 2023

I am making this contribution with a shared copyright between me as an individual and @wikimedia foundation. I don't know whether this contribution is copyrightable or subject to CLA, if it can be opted out feel free to merge it in.

Meanwhile I will reach out to @wikimedia legal department to review and sign the OpenJS CCLA which I can not sign in name of the organization.

@zeljkofilipin
Copy link

@hashar I have contacted @wikimedia legal team while working on #7999. I think the CLA is signed. They will probably know what to do, but as far as I remember, you have to add your wikimedia email to your github profile and sign the commit with it.

https://github.com/settings/emails

When requesting a screenshot in the `afterTest` hook, I would sometime
not have any screenshot generated. I eventually found
`browser.saveScreenshot` is an async function and the hook has to be
explicitly defined `async`:

webdriverio#5545 (comment)

Add an example to the `browser.saveScreenshot` documentation showing how
to use it in the `afterTest` hook.

Signed-off-by: Antoine Musso <amusso@wikimedia.org>
@hashar
Copy link
Contributor Author

hashar commented Aug 25, 2023

I have amended the commit message to add:

 Signed-off-by: Antoine Musso <amusso@wikimedia.org>

But EasyCLA still fails. That is now pending approval of my account by the Wikimedia Legal team :)

@erwinheitzman
Copy link
Member

erwinheitzman commented Aug 28, 2023

Honestly this applies to all commands you use, not just in a hook but everywhere, so I don't really see a benefit in explicitly adding this.

It also applies to all hooks that they have to be async when awaiting any promise.

@christian-bromann
Copy link
Member

Any updates @hashar ?

@hashar
Copy link
Contributor Author

hashar commented Sep 6, 2023

Any updates @hashar ?

I went ahead and signed an individual CLA since I have shared copyright for the work I am doing while working for Wikimedia. I will still reach out to our the organization legal team to find out how to get added to the corporate CLA as well.

I have no idea how to retrigger EasyCLA verification :)

@hashar
Copy link
Contributor Author

hashar commented Sep 6, 2023

Honestly this applies to all commands you use, not just in a hook but everywhere, so I don't really see a benefit in explicitly adding this.

It also applies to all hooks that they have to be async when awaiting any promise.

I guess the issue I have is I am not familiar with JavaScript and got caught on calling the browser.saveScreenshot without an await cause the hook does not have async by default, at least it did not have it at the time we generated the wdio.conf.js and it seems online documentation do not explicitly mention the hooks are async. I blame myself for my poor familiarity with Javascript and hoping this documentation my save someone some hours figuring out why screenshots are not taken :]

@christian-bromann
Copy link
Member

@linux-foundation-easycla
EasyCLA — EasyCLA check passed. You are authorized to contribute.

It is actually passing now, thanks for getting the approval

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@christian-bromann christian-bromann added the PR: Docs 📝 PRs that contain changes to the documentation label Sep 6, 2023
@christian-bromann christian-bromann merged commit 8539bc4 into webdriverio:main Sep 6, 2023
@hashar
Copy link
Contributor Author

hashar commented Sep 8, 2023

Any updates @hashar ?

I went ahead and signed an individual CLA since I have shared copyright for the work I am doing while working for Wikimedia. I will still reach out to our the organization legal team to find out how to get added to the corporate CLA as well.

I have no idea how to retrigger EasyCLA verification :)

As a follow-up, I got added to the Wikimedia Foundation contributors and signed the corporate CLA through EasyCLA. Success!

@christian-bromann
Copy link
Member

Nice 🎉 looking forward to more contributions then 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Docs 📝 PRs that contain changes to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants