WebDriver Automation for Prisma Browser
Focus
Focus
Prisma Browser

WebDriver Automation for Prisma Browser

Table of Contents

WebDriver Automation for Prisma Browser

This is the page for Webdriver Integration
Where Can I Use This?What Do I Need?
WebDriver automation enables scripted tests to run on Prisma Browser within CI/CD pipelines and automated environments. It allows automation frameworks to control the browser programmatically for validation, regression testing, and workflow simulation.
Prisma Browser officially supports automation testing with Playwright and Selenium.
Using automation tokens may bypass certain security controls enforced in normal user sessions. All use is at your organization's risk.

Prerequisites

Before you configure automatic testing with Prisma Browser, you need to perform the following steps:
  1. Make sure that Prisma Browser 146.3.xx or above is installed.
  2. Generate am automation token AdministrationIntegrations WebDriver Automation. This token is needed to authenticate automation sessions.
    For login and auditing purposes, the token must be associated with a local user account. The configuration is a two-step process:
    1. Configure a CIE directory with local users
    2. \Sync the directory to your Prisma Browser setup
  3. Set the automation token as an environment variable on the machine running your scripts:
    • PRISMA_BROWSER_AUTOMATION_TOKEN
  4. Enable Developer Tools for the local user accounts used during automation.
    • The policy is found under Access & Data Control > Controls and Data profiles > Developer Tools on web pages. Scope this to the relevant local users.
  5. Disable the Onboarding Wizard for automation accounts to ensure clean recordings
    • The policy is located under Create RuleBrowser CustomizationOnboarding Wizard.
  6. Download the WebDriver for Selenium-based testing.
    Playwright works out-of-the-box and does not require a separate WebDriver installation.

How Browser Automation Works

When the automation token environment variable is set:
  • Prisma Browser reads the token from the environment upon launch.
  • The browser automatically authenticates using the associated service user.
  • WebDriver connectivity is enabled only when the environment variable is present.

Security Note

By default, Prisma Browser blocks all WebDriver connections. The automation token environment variable acts as the key that safely permits WebDriver automation.

Configure the Prisma Browser WebDriver

The Prisma Browser WebDriver is only needed when running Selenium-based automation scripts.
  1. Download the WebDriver for Windows x64 or macOS
    The WebDriver version must match the version of the browser you are testing.
  2. Install the WebDriver on the device where automation scripts will run.
  3. Reference the path to the WebDriver in your Selenium scripts.
(macOS only): You must allow the WebDriver through the Gatekeeper. See the "Allowing the WebDriver to Run" section below.

Sample Test Scripts

Playwright Sample Script
python import os import tempfile import shutil TARGET_URL = "https://www.google.com" TIMEOUT_SECONDS = 10 # Detect the operating sfrom playwright.sync_api import sync_playwright import time import platform ystem current_os = platform.system() # Set browser path and user data directory based on OS if current_os == "Darwin": PB_BROWSER = "/Applications/Prisma Access Browser.app/Contents/MacOS/Prisma Access Browser" # Always use explicit user-data-dir to avoid platform-specific issues USER_DATA_DIR = os.path.join(tempfile.gettempdir(), "playwright-pab-userdata") elif current_os == "Windows": PB_BROWSER = r"C:\Program Files\Palo Alto Networks\PrismaAccessBrowser\Application\PrismaAccessBrowser.exe" USER_DATA_DIR = os.path.join(os.getenv('TEMP'), "playwright-pab-userdata") elif current_os == "Linux": PB_BROWSER = "/usr/bin/prisma-access-browser" USER_DATA_DIR = os.path.join(tempfile.gettempdir(), "playwright-pab-userdata") else: raise Exception(f"Unsupported operating system: {current_os}") print(f"Detected OS: {current_os}") print(f"Browser path: {PB_BROWSER}") print(f"User data directory: {USER_DATA_DIR}") def main(): start_time = time.time() with sync_playwright() as p: print("Starting Playwright Session...") try: context = p.chromium.launch_persistent_context( user_data_dir=USER_DATA_DIR, executable_path=PB_BROWSER, headless=False, args=[ # --remote-debugging-port=9222 # Uncomment to specify port explicitly. Assure the port is available. ], ) page = context.new_page() print(f"Navigating to {TARGET_URL}...") page.goto(TARGET_URL) page.wait_for_load_state('networkidle') print(f"Page loaded successfully.") print(f"Page title: {page.title()}") print(f"Waiting for {TIMEOUT_SECONDS} seconds...") time.sleep(TIMEOUT_SECONDS) end_time = time.time() elapsed_time = end_time - start_time print(f"\nTimeout completed.") print("Closing browser...") except Exception as e: print(f"Error: {e}") raise # Cleanup after playwright context is closed print(f"Cleaning up user data directory: {USER_DATA_DIR}") # Wait for browser to fully release file locks time.sleep(2) try: shutil.rmtree(USER_DATA_DIR) print("✓ User data directory deleted successfully") except Exception as e: print(f"✗ Could not delete directory: {e}") print(f" Manual cleanup required: {USER_DATA_DIR}") print("Browser session closed. Script ended.") if __name__ == "__main__": main()
Selenium Sample Script
python import time import platform from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options TARGET_URL = "https://www.google.com" TIMEOUT_SECONDS = 10 # Detect the operating system current_os = platform.system() # Set browser path and PrismaDriver path based on OS if current_os == "Darwin": # macOS PB_BROWSER = "/Applications/Prisma Access Browser.app/Contents/MacOS/Prisma Access Browser" PRISMADRIVER_PATH = "" #add prismadriver path:sample--/Users/user1/Downloads/prismadriver" elif current_os == "Windows": PB_BROWSER = r"C:\Program Files\Palo Alto Networks\PrismaAccessBrowser\Application\PrismaAccessBrowser.exe" PRISMADRIVER_PATH = r"" #add prismadriver path:sample--C:\Users\user1\Desktop\prismadriver.exe" elif current_os == "Linux": PB_BROWSER = "/usr/bin/prisma-access-browser" PRISMADRIVER_PATH = "" #add prismadriver path:sample--/home/user1/Downloads/prismadriver else: raise Exception(f"Unsupported operating system: {current_os}") print(f"Detected OS: {current_os}") print(f"Browser path: {PB_BROWSER}") print(f"PrismaDriver path: {PRISMADRIVER_PATH}") print("Note: Selenium will create and manage a temporary profile automatically") def main(): print("Starting Selenium Session...") # Configure Chrome options chrome_options = Options() chrome_options.binary_location = PB_BROWSER #chrome_options.add_argument("--remote-debugging-port=9222") # Uncomment to specify port explicitly.Assure the port is available. #chrome_options.add_argument("--headless") # Uncomment for headless mode # Note: No --user-data-dir specified = Selenium creates and cleans temp profile automatically #chrome_options.add_argument("--user-data-dir=") # Uncomment to set a user data dir. # Create service service = Service(executable_path=PRISMADRIVER_PATH) driver = None try: # Launch browser driver = webdriver.Chrome(service=service, options=chrome_options) print(f"Navigating to {TARGET_URL}...") driver.get(TARGET_URL) print(f"Page loaded successfully.") print(f"Page title: {driver.title}") print(f"Waiting for {TIMEOUT_SECONDS} seconds...") time.sleep(TIMEOUT_SECONDS) print(f"\nTimeout completed.") print("Closing browser...") except Exception as e: print(f"Error: {e}") raise finally: if driver: driver.quit() print("Browser session closed. Script ended.") print("(Temporary profile automatically cleaned up by Selenium)") if __name__ == "__main__": main()

Run WebDriver on macOS

  1. Open System Settings.
  2. Select Privacy and Security.
  3. Scroll down to Security.
  4. You should see a message "prismadriver" was blocked by your mac.
  5. Click Open anyway.
  6. When prompted, click Open to confirm.
As an alternative, you can run the following:
xattr -d com.apple.quarantine/path/to/prismadriver
This removes the quarantine flag and avoids the graphical user interface step entirely.