0

I'm aware of selenium (but for some reason, the real page that has a complex HTML, I couldn't retrieve it well using DOM, so I eventually give up - I'm trying luck with FlaUI). To start out, I'm trying some simple task such as open a page and click on a button. But it isn't working. It didn't result in any error, the application seems to just hangs. What am I missing?

my code:

    var process = Process.Start(@"C:\Program Files\Mozilla Firefox\firefox.exe",
                                "file:///C:/Users/jckj33/Desktop/button.html");
    //process.WaitForInputIdle();
    var app = FlaUI.Core.Application.Attach(process.Id);
    Debug.WriteLine("wating...");
    app.WaitWhileBusy();
    Debug.WriteLine("waiting done!!");
    Thread.Sleep(5000);
    using (var automation = new UIA3Automation())
    {
        var window = app.GetMainWindow(automation);
        var button = window
            .FindFirstDescendant(cf => cf.ByControlType(FlaUI.Core.Definitions.ControlType.Button))
            .AsButton();
        button?.Invoke();
    }

where button.html is:

<input type='button' value='Click me' onclick='alert("hello, world!")'>
Jack
  • 16,276
  • 55
  • 159
  • 284
  • 2
    That's not a Windows button. You need to use a *browser* automation tool , like Selenium or [Playwright](https://playwright.dev/dotnet/docs/intro). Browsers allow automation, mainly for testing, through the cross-platform WebDriver interface – Panagiotis Kanavos Jan 30 '23 at 15:47
  • I see, post it as answer so I can asnwer then. I'll try luck with Playwright and whatnot – Jack Jan 31 '23 at 16:50

0 Answers0