Basic Authentication for Web Pages


Basic Authentication is a simple and effective way to secure web pages. You can perform this easily by passing the authentication details directly via the URL. This article discusses how to perform basic authentication for web pages.


Passing Authentication Details via URL

We can use the below format for Basic Authentication:

Format:

[protocol]://[username]:[password]@hostname

This format will have the protocol (HTTP or HTTPS), username, and password.

For Example:

In the NLP, Navigate to test data, replace the test data with https://admin:admin123@orangehrm.com.

Basic Authentication

When we navigate to the host URL, the browser automatically sends the credentials for Authentication. We need to use HTTPS to secure sensitive information.


Reducing Execution Time on Safari in Mobile Web

When testing web applications on Safari or mobile browsers, passing credentials directly in the URL (for example, https://admin:admin123@orangehrm.com) may increase step execution time.

To overcome this and speed up execution, instead of passing the credentials in the URL, we can pass them as a custom header using Desired Capabilities.

Configuration

Key Type Value
testsigma.customHeaders String {"Authorization":"Basic YWRtaW46YWRtaW4xMjM="}

Desired Capability

Steps to Generate Base64 Credentials

Combine the username and password in the format username:password, and then convert this string to Base64 encoding.

For Example:

In the URL: https://admin:admin123@orangehrm.com

Username: admin

Password: admin123

Base64 encoded value: YWRtaW46YWRtaW4xMjM=

NOTE:

You can generate the Base64 encoded value using any standard online Base64 encoding tool.

Once the desired capability is set, the browser authenticates through the header and prevents the additional execution delay observed in Safari.