How to execute the hook to download a file that is being downloaded on lambdatest to local machine when using tunnel with webdriverio and typescript

Hello. I am using webdriverio with typescript. The test verifies that a file has to be downloaded at one point. The file is being downloaded to lambdatest. However I need it on my local machine to verify its type and to perform additional actions with it. The project that is tested is running on localhost so a tunnel is used to execute the script on lambdatest. I found the suitable hook but I am unable to use it properly. Can you please provide an example?

Hi,

Please allow us sometime and we will get back to you

Hello,

As per your use case, once the file is downloaded you can read the file content and convert it in base64EncodedFile and then write it in the root directory of your project using the below command.

// Download file content const base64EncodedFile = await browser.execute('lambda-file-content=file_name.file.extension); console.log(base64EncodedFile);

// Decode base64 and write to file const data = Buffer.from(base64EncodedFile, ‘base64’); fs.writeFileSync('file_name.file.extension, data);

Please find the sample repo in WebdriverIO for your use case: