Configure PAC files for Local Testing on Appium
Work with PAC files to establish a Local Testing connection to run Appium tests on BrowserStack App Automate.
If your internal network routes traffic through a proxy defined by a PAC file, you can point BrowserStack Local at that file so your Appium tests can reach privately hosted apps. Set it up through your test script’s language bindings or the Local binary command line.
PAC (Proxy Auto-Configuration)
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 two ways:
Via language bindings:
Add the following snippet to your test scripts:
bsLocalArgs.put("-pac-file", "pac_file_abs_path");
bs_local_args = { 'key': 'YOUR_ACCESS_KEY', 'pac-file': 'pac_file_abs_path' }
bsLocalArgs.Add(new KeyValuePair{string, string}("-pac-file", "pac_file_abs_path"));
$bs_local_args = array("key" => "YOUR_ACCESS_KEY", "-pac-file" => "pac_file_abs_path"
bs_local_args = { "key": "YOUR_ACCESS_KEY" , "-pac-file": "pac_file_abs_path"}
bs_local_args = { "key" => "YOUR_ACCESS_KEY" , "-pac-file" => "pac_file_abs_path"}
Via command-line interface:
Establish the Local Testing connection using --pac-file flag, along with the PAC file’s absolute path.
Run the binary using the following command:
./BrowserStackLocal --key YOUR_ACCESS_KEY --pac-file pac_file_abs_path
BrowserStackLocal.exe --key YOUR_ACCESS_KEY --pac-file pac_file_abs_path
Note: We do not support authentication with PAC file at the moment.
To resolve all requests on our remote browsers and mobile devices through your PAC proxy, add --force-proxy and --force-local flags to the command.
Without these flags, Local binary tries to connect directly for enhanced performance.
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
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!