Tuesday, April 25, 2023

NTLM authentication for Cypress

cypress-ntlm-auth

Install the cypress-ntlm-auth package by using the below commands

npm install --save-dev cypress-ntlm-auth

After successfully installing the plugin, we can see the NTLM information in the package.json file






The --save-dev flag stores cypress-ntlm-auth as a development dependency suitable for a testing utility.

Commands

In the file cypress/support/commands.js (or .ts) add this line

import "cypress-ntlm-auth/dist/commands";

Refer to the below example 

Create a function in utility > common.js & use it in another spec file


NOTE: Make sure the HOSTNAME is correct.

See the below example: Import in the spec file and use that function


Now, we are done with our configuration.

The most convenient way to start Cypress with NTLM authentication is

npx cypress-ntlm open

EXAMPLE - Error Message: Not properly configured for NTLM

EXAMPLE - Success Message: Properly configured for NTLM

That is it! Thank you very much for reading!

Refer URL: https://www.npmjs.com/package/cypress-ntlm-auth

No comments:

Post a Comment