Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
editable text, find accessible object
#7
Tested, Playwright can be used.

Setup (if you don't have Playwright and Playwrighter): see Cookbook recipe "Web browser automation with Playwright".

Script to run your program with Playwright connections enabled:
 
Code:
Copy      Help
Environment.SetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--remote-debugging-port=9225");
run.it(@"C:\path to your program.exe");

Script to show the Playwright recorder for your app:
 
Code:
Copy      Help
// script "Test Playwright WebView2 - record.cs"
/*/ c Playwrighter.cs; /*/

using var play = Playwrighter.Connect(out var page, "*", new(9225), debug: true);
var w1 = wnd.find(10, "Playwright Inspector*", "Chrome_WidgetWin_1");
w1.WaitForClosed(0);

The Playwright recorder does not work well in "connect" mode. Recording works, but it leaves some artifacts in the UI, and next time recording does not work. After recording, restart your app.

Example script that finds and clicks a link in your app:
Code:
Copy      Help
// script "Test Playwright WebView2.cs"
/*/ c Playwrighter.cs; /*/
using Microsoft.Playwright;

using var play = Playwrighter.Connect(out var page, "*", new(9225));
print.it(page.Url);

//this code was recorded with the Playwright recorder (copied from its window)
await page.GetByRole(AriaRole.Link, new() { Name = "Forum" }).ClickAsync();


Messages In This Thread
RE: editable text, find accessible object - by Gintaras - 06-04-2025, 04:29 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)