The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing

Insights

External Resources

More Info


Page tree
Skip to end of metadata
Go to start of metadata

In Safari, when you try to navigate to a URL that uses basic HTTP authentication, a warning dialog pops up that will derail your automated tests unless you can resolve it. You can use a short shell script that you execute as a pre-run executable to configure Safari to not show this message.

Safari Versions

 You can only use this for Safari versions up to and including 10.x.

The Script

#!/bin/bash 
defaults write com.apple.Safari WarnAboutFraudulentWebsites false

This script clears the Warn when visiting a fraudulent website option in Safari's preferences, so that your automated tests that use basic authentication over HTTP will execute without triggering the warning. 

This script is hosted as a Gist on GitHub: https://gist.githubusercontent.com/saucyallison/3a73a4e0736e556c990d/raw/d26b0195d48b404628fc12342cb97f1fc5ff58ec/disable_fraud.sh

Setting the prerun Capability

You can host this script in your own repository, or in temporary Sauce Storage, and refer to it within the prerun capability of your tests as described in the Test Configuration Options topic. This Python example refers to the GitHub Gist location:

desired_capabilities['prerun'] = { 
  'executable':'https://gist.githubusercontent.com/saucyallison/3a73a4e0736e556c990d/raw/d26b0195d48b404628fc12342cb97f1fc5ff58ec/disable_fraud.sh', 
    'background': 'false' 
}