Basic authentication on real iOS devices with safari

Hey together, I want to test a mobile website on a real iOS device. The site is “secured” with a basic authentication.

I try to open my site like: await driver.get(“https://user:password@stage.mywebsite.com/”);

The iPhone shows me always the basic auth pop up.

Is there any option to handle this?

Thanks a lot

1 Like

Basic Auth is mainly supported for Google Chrome. We do have the workaround for Basic auth in Safari in manual testing. For that, you must have tunnel installed in your system. Here is the link for the same: Perform Testing Of Locally Hosted Web Pages | LambdaTest

Once you will install the tunnel successfully, then follow the below mentioned steps:

  1. Go to Command Prompt(for windows) and open the Tunnel folder.

  2. Pass the below command in the Tunnel: LT --user --key <access_key> -b https://admin:admin@the-internet.herokuapp.com/basic_auth –mitm

Here you would need to mention your User name and access key. Also, admin:admin in the above command is the username and password of the URL(The Internet) so we would need to change the command as per our website and the credentials.

  1. Once you will pass the command shared in step 2, it will look something like this:

  2. Once your tunnel will start and running, you need to go to LT dashboard and mention the URL in the bar as shown below:

  3. That it, you can launch the session and can perform the testing.

Hope that helps. If you still need any help or have any queries, just drop us an email to support@lammbdatest and we will look into it.

Happy Testing!

thanks for the manual solution. In our case we need the automated way.

If you wish to achieve this in Automation, then the Steps from 1 to 3 will be the same. After step 3, just go to your script and mention the URL for which you wanted to test the Basic Auth and run your test. It will work.

Here is how you need to pass the URL in the script if you are using Java. driver.get(“https://the-internet.herokuapp.com/basic_auth”);

Thread.sleep(5000);

Let us know if you have any questions.