Basic Authentication for Safari Web Automation
Introduction
Basic Authentication is a method for an HTTP user agent to provide a user name and password when making a request. In basic HTTP authentication, a request contains a header field in the form of Authorization: Basic <credentials>
, where credentials is the Base64 encoding of ID and password joined by a single colon :
.
To provide support for Basic Authentication in Safari during Web Automation, we have introduced a new lambda hook in our iOS
Real Device (RD) web sessions.
- This hook is not compatible with any app-based sessions.
- The capability
autoAcceptAlerts
must be set tofalse
.
How to Use
Here is an example of how to use the Basic Authentication hook in Python:
data = {
"username": "admin",
"password": "admin",
"url": "https://the-internet.herokuapp.com/basic_auth",
}
driver.execute_script("lambda-ios-set-basic-auth", data)
It is important to note that all three parameters (username, password, URL) are mandatory and must be passed to the script.
Limitations
Please note, this hook is designed to be used exclusively with Safari on iOS Real Device (RD) web sessions and is not compatible with Android sessions or any app-based sessions.