Skip to main content
Experience faster, smarter testing with BrowserStack AI Agents. See what your workflow’s been missing. Explore now!
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

Configure PAC files for Local Testing on Puppeteer

Work with PAC files to establish a Local Testing connection to run Puppeteer tests on BrowserStack Automate. Automated website testing on real device cloud.

PAC file (Proxy auto-configuration file) contains a Javascript function that determines whether a request should be sent via the proxy server.

Once you have the absolute path of the PAC file on your machine, you can establish a Local Testing connection using one of the following ways:

If you are using the BrowserStack SDK, add the following snippet to your browserstack.yml file:

browserStackLocalOptions:
  pacFile: <pac_file_abs_path>

Sample PAC file

The following function checks to see whether the hostname is localhost, and if so, whether the connection is direct. If the hostname is not localhost, the connection is via proxy.

function FindProxyForURL(url, host) {
  if (isPlainHostName(host))
    return "DIRECT";
  else
    return "PROXY proxy:80";
}

If you don’t understand the proxy script or are not authorized to make any changes to it, contact your IT/Network team.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle