To inspect and debug WebView2-based applications, you must configure a Windows environment variable to enable remote debugging. This configuration allows Ranorex Studio to access the elements within the application.
Before you start
Before inspecting and debugging your application, ensure you address the following:
- Close existing instances: Close all WebView2 applications before starting your Application Under Test (AUT) to free up the debugging port.
- Background processes: Open the Task Manager and verify that no WebView2 processes remain active in the background.
Set the environment variable
You enable remote debugging by adding the following environment variable to your system:
- Variable: WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS
- Value: --remote-debugging-port={port number} --remote-allow-origins=*
Replace {port number} with a port number, for example, --remote-debugging-port=9955
Important notes
- Port consumption: The first WebView2 application that starts consumes the specified port. If multiple WebView2 apps run simultaneously, the port remains occupied, which prevents the debugging of other applications.
- Port availability: If the port is already in use by another service, Ranorex Studio cannot attach to the WebView2 control. Ensure the chosen port is free before starting your test.