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

Incorrect example for element.takeScreenshot() #4120

Closed
dikwickley opened this issue Mar 12, 2024 · 1 comment · Fixed by #4121
Closed

Incorrect example for element.takeScreenshot() #4120

dikwickley opened this issue Mar 12, 2024 · 1 comment · Fixed by #4121

Comments

@dikwickley
Copy link
Contributor

Description of the bug/issue

The example present for .takeScreenshot() at https://nightwatchjs.org/api/element/takeScreenshot.html
throws error.

This is because the node js fs.writeFile() expects a callback at the end
https://nodejs.org/en/learn/manipulating-files/writing-files-with-nodejs

Steps to reproduce

Running a test using the example mentioned gives the following error

aniket@air nightwatch % node ./bin/nightwatch ./sample/screenshot.js --chrome


[Screenshot Demo] Test Suite
────────────────────────────────────────────────────────
ℹ Connected to ChromeDriver on port 9515 (981ms).
  Using: chrome (122.0.6261.112) on MAC.


  Running Demo:
───────────────────────────────────────────────────────────────────────────────────────────────────
  ✔ Element <body> was visible after 1222 milliseconds.

  ✨ PASSED. 1 assertions. (1.292s)
  Error
   unhandledRejection: The "cb" argument must be of type function. Received type string ('base64')
TypeError [ERR_INVALID_ARG_TYPE]: The "cb" argument must be of type function. Received type string ('base64')
    at maybeCallback (node:fs:177:3)
    at Object.writeFile (node:fs:2272:14)
    at /Users/aniket/Projects/gsoc/nightwatch/sample/screenshot.js:14:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

───────────────────────────────────────────────────────────────────────────────────────────────────

  ️TEST FAILURE (3.191s): 
   - 1 error during execution; 
   - 0 tests failed; 
   - 0/NA tests passed

Sample test

No response

Command to run

No response

Verbose Output

No response

Nightwatch Configuration

No response

Nightwatch.js Version

3.4.1

Node Version

No response

Browser

No response

Operating System

No response

Additional Information

No response

@hiirrxnn
Copy link

Can i work on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants