Automating Basic Authentication in Safari


Safari restricts automated Basic Authentication login by blocking credentials in the URL format, which is a challenge in automation testing. In Testsigma, you can bypass this limitation using an encoded Authorization header in the desired capabilities. This article discusses generating the necessary authorization token and configuring capabilities.


Prerequisites

Before you begin, ensure that you have referred to:

  1. Documentation on creating test cases.
  2. Documentation on performing Ad-Hoc runs.
  3. Documentation on managing desired capabilities in Testsigma.

Generate the Authorization Header

  1. Navigate to Basic Auth Header Generator.
  2. Enter your username and password to generate the Authorization Header.

    Auth Header


Adding the Capability

  1. On the Test Case Details page, click Run. Run
  2. In the Ad-Hoc Run overlay,

    • Select available macOS, Version, Browser, and Resolution. Machine, Ver, Browser & Resol
    • Enter testsigma.customHeaders in the Key field, select String as Data type, and set the Value as per the generated Authorization Header. Desired Capabilities

      Value Format: { "Authorization": "Basic <token>" }

  3. Click Run Now to execute the test case. Execute Test
  4. After execution completes, refer to the screenshot captured at the test step level. Screenshot of Execution
NOTE:

This capability is available only for the Safari browser.