Forum Discussion

DanNad's avatar
DanNad
Contributor
11 months ago

WebView2 support does not work

Hello everyone. Did someone manage to get this to work?

There is no documentation on webview2 and also smartbear support doesnt seem to know how we can get this to work. We tried a lot of different approaches already but the object spy does not recognize the objects within the webview2 window.

Support gave us the string "--edge-webview-switches=--remote-debugging-port=92223" and we are supposed to add it to the command line field in TestedApps but this doesnt seem to make sense because i dont know how our proprietary software is supposed to know this command line parameter. I tried it anyways but our software is giving us an error message on startup stating the switch is invalid.

I managed to get this to work with our selenium project where we also use the remote debugging port to enable the webdriver to attach to the webview2 process. But i cant figure a way out how this should work with testcomplete.

17 Replies

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    I've been looking into this, and learning about WebView2. I have a simple C# WebView2 forms application that displays a web site.

    C# WebView2 form application

    The Object Browser shows the following

    Standard UI controls exposed

    Enabling MSAA (TC -> Project Settings), exposes the controls of the application

    Application controls exposed

    Enabling UI Automation (TC -> Project Settings), exposes even more of the application

    More controls exposed of the application

    and also WebView2, including the UI controls within

    WebView2 and all UI controls with

    For this to work correctly, the appropriate flag settings needs to be enabled for WebView2 control within the application.

    Using TC version

    If you're using Selenium WebDriver, then you can use the following command (I haven't tested this)

    var environment = await CoreWebView2Environment.CreateAsync(null, null, new CoreWebView2EnvironmentOptions("--remote-debugging-port=9222"));
    await webView.EnsureCoreWebView2Async(environment);
    

    I hope this helps, and gives you a starting point.

    • DanNad's avatar
      DanNad
      Contributor

      I expect Testcomplete to let me map the objects that are displayed inside of the webview2 windows like other cross browser enabled mappings (e.g. using xpath, css selectors and so on)

      This does not work. Enabling UI Automation (TC -> Project Settings) doesnt let me do that and this also worked in earlier versions of testcomplete where there was no webview2 support.

      Currently our only option is to make a selenium project which uses the remote debugging port and integrate it into the testcomplete testscripts.

    • DanNad's avatar
      DanNad
      Contributor

      yes of course i use the latest testcomplete version

      • Marsha_R's avatar
        Marsha_R
        Icon for Champion Level 3 rankChampion Level 3

        We have to ask because there is no "of course" with community users. Every user does things differently and many people leave details out of their posts because they are making assumptions as well.  :D

  • Its the second Testcomplete version (15.70) that states either Web View 2 is supported or there were improvements made to Web View 2 support. Still there is zero article in the Testcomplete documentation pages that tells the user how to get this to work.

    Can someone on here tell how to get this to work?

    • Michael_B's avatar
      Michael_B
      Contributor

      No luck with v15.71. Maybe I'm missing a setting. Is there somewhere I need to add the support specifically? I see that it has been supported since v15.69 but don't see anything about it specifically in on the support site.

      • DanNad's avatar
        DanNad
        Contributor

        Same for us. 15.71 and its still not working. This is very very disappointing

  • BD_Geoactive's avatar
    BD_Geoactive
    Occasional Contributor

    I have an embedded WebView2 components within our desktop application (.NET/Winform) - I've found that i couldn't expose the contents of the component inside/under the WebView2 parent object.

    I have ensure the settings as you suggested in the post above are used in my T.C project setting

    • rraghvani's avatar
      rraghvani
      Icon for Champion Level 3 rankChampion Level 3

      It still works in TC v15.77.6.7

       

  • Hassan_Ballan's avatar
    Hassan_Ballan
    Icon for Champion Level 3 rankChampion Level 3

    Sharing some findings that might help others evaluating WebView2 with TestComplete:

    🔎 Current Observations

    • While TestComplete versions since 15.69 mention WebView2 support, there’s still no official documentation on how to achieve full object recognition inside the control.
    • Based on community reports, DOM-level mapping via XPath/CSS selectors (as in typical web testing) is still not working.
    • UI Automation can expose some UI elements within WebView2, but not actual web content in many setups.

    🛠️ Technical Option to Explore

    For teams able to modify the application, you might consider enabling remote debugging on the WebView2 control. Example (C#):

    var env = await CoreWebView2Environment.CreateAsync(
        null, null, new CoreWebView2EnvironmentOptions("--remote-debugging-port=9222"));
    await webView.EnsureCoreWebView2Async(env);
    

    Then attach a Selenium session:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    opts = Options()
    opts.add_experimental_option("debuggerAddress", "localhost:9222")
    driver = webdriver.Chrome(options=opts)
    

    This can provide DOM access to WebView2 content, similar to how Chrome DevTools works.

    🔧 Notes

    • This approach may not work for all applications — especially if the WebView2 environment can't be configured to allow remote debugging.
    • It requires coordination with development to set up correctly.
    • A few users in the community have partially validated this, but no complete end-to-end examples are available yet.

    Hopefully, this gives others a direction to investigate further while waiting for clearer support from SmartBear.

    🤖 AI-assisted response
    👍 Found it helpful? Click Like
    ✅ Issue resolved? Click Mark as Solution