If you are using Laravel Dusk to test an external website and if the website is secured with basic HTTP Authentication (which is usually the case with staging and dev sites) you can use this trick.

Http Authentication

Append the username and password just before the url

'http://UserName:Password@www.example.com'

So in dusk you can visit the URL by

$browser->visit('http://UserName:Password@www.example.com')

Or you can set the APP_URL in the .env file directly.

APP_ENV = http://UserName:Password@www.example.com

This way, the website won't prompt with a javascript alert box for the login details and will directly log you into the website.

Comments