To inspect and debug WebView2-based applications, it's important to configure a Windows environment variable to enable remote debugging.
Set the environment variable
Set the environment variable by adding the variable and value:
- 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
By following these steps you can successfully inspect and debug your WebView2 application:
- Ports: The specified port is consumed by the first starting WebView2 application. If multiple WebView2 applications are running, the port might be already in use, which may prevent other apps from being debugged.
- Ensure apps are closed: Before starting your application under test (AUT), close all WebView2 applications to free up the debugging port.
- Check background processes: Use Task Manager to verify that no WebView2 apps are running in the background.