gauge-ts icon indicating copy to clipboard operation
gauge-ts copied to clipboard

Can't save a screenshot with selenium webdriver

Open tjoooobooo opened this issue 5 years ago • 3 comments

Describe the bug I'm trying to implement the CustomScreenshotWriter with gauge-ts and selenium but it doesn't work. It saves the screenshot but I suppose gauge requires an Uint8Array as the screenshot file but selenium does return a string as the screenshot. So if I run the code I only get the output a.charCodeAt() is not a function.

To Reproduce Steps to reproduce the behavior:

  1. Install gauge-ts
  2. Install selenium-webdriver
  3. Use given function for screenshots
 @CustomScreenshotWriter()
    public async takeScreenshot(): Promise<string> {

        return WebDriverManager.call(driver => {
            return new Promise((resolve, reject) => {

                driver.takeScreenshot()
                    .then(screenshot => {
                        let screenShotFilePath = join(
                            process.env['gauge_screenshots_dir'],
                            `screenshot-${v4()}.png`
                        );

                        writeFileSync(screenShotFilePath, screenshot);
                        resolve(basename(screenShotFilePath));
                    })
                    .catch(err => reject(err))
                ;
            });
        });
    }

Desktop (please complete the following information):

  • OS: linux
  • Gauge and plugin version [run gauge -v]
Gauge version: 1.1.5
Commit Hash: f455126

Plugins
-------
html-report (4.0.12)
js (2.3.14)
json-report (0.3.5)
screenshot (0.0.1)
ts (0.1.0)
  • Node version [run node -v]
v14.15.1
  • Npm version [run npm -v]
6.14.8

tjoooobooo avatar Nov 18 '20 18:11 tjoooobooo

Method implementing CustomScreenshotWriter should return a file path (string). Now how the file is created it's totally up to you

BugDiver avatar Nov 19 '20 11:11 BugDiver

If I change to following code like that:

let screenShotFilePath = join(
process.env['gauge_screenshots_dir'],
`screenshot-${v4()}.png`
);

writeFileSync(screenShotFilePath, screenshot);
_**resolve(screenShotFilePath);**_

the file path will be returned, but the test step output in console only is:

 Error Message: a.charCodeAt is not a function
        Stacktrace:

tjoooobooo avatar Nov 19 '20 11:11 tjoooobooo

Could you please provide a sample project which can be used to replicate the issue?

On Thu, 19 Nov 2020 at 4:59 PM, tjoooobooo [email protected] wrote:

If I change to following code like that:

let screenShotFilePath = join( process.env['gauge_screenshots_dir'], screenshot-${v4()}.png );

writeFileSync(screenShotFilePath, screenshot); resolve(screenShotFilePath);

the file path will be returned, but the test step output in console only is:

Error Message: a.charCodeAt is not a function Stacktrace:

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/BugDiver/gauge-ts/issues/123#issuecomment-730311948, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADUZYNJR37TXDSZVY277EI3SQT6STANCNFSM4T2KORUQ .

BugDiver avatar Nov 19 '20 11:11 BugDiver