Search code examples
vb.netmicrosoft-edgemicrosoft-ui-automation

UI Automation to navigate Microsoft Edge without going through Selenium?


I'm developing some UI Automation work for a WPF program in VB.Net and have had great success. . . until trying to automate Web Browsers.

With Chrome there's --force-renderer-accessibility which was a Godsend, but it appears despite having been built off of Chromium they've disabled this flag on Microsoft Edge. . .

is it possible they have renamed the flag? Anyone else know how to force Microsoft Edge to be in accessibility mode? I have looked at this SO Article but it seems this wasn't really a good answer, nor a good question (the first link in the answer has been removed from SO altogether. . . ).

Is there any good documentation/examples of using the WebDriver API from the linked SO Article, or does this point right back to Selenium???


Solution

  • I have had some more time to dig into this and play a little further. I found this article (a bizarre place to find such information) and modified my registry as described. I have 3 scenarios now which I'm baffled by, but after testing the registry change, AND after re-running MSEdge from command line using the --force-renderer-accessibility flag (after setting my registry back to the original setting to confirm accuracy), I think it is safe to say this same flag we have come to love in Chrome still works in MSEdge.

    TLDR: The difference? MSEdge buries EVERYTHING in what feels like 1,000 layers DEEP compared to Chrome, and the "" region entries REALLY threw me off. You want to still look for the Chrome Legacy Window (counterintuitively) and then search for your element(s) within that pane. (FWIW, This also threw me off, because with Chrome, normally if I see this, I recall the flag not taking appropriately so I was reticent to click past this within Inspect.) /END TLDR

    Without modifying my registry, I can find this Advanced button in the tree.

    Advanced Button

    It gives me a TON of errors as shown,, but the button is there, albeit the text from the page is not.

    Errors, No Text shown from page.

    If I change the registry setting, I get the text, but still get all the errors for the element.

    Errors, and Text shown.

    Lastly, if I open MSEdge.exe via this command: start "Title for fun here" msedge.exe --force-renderer-accessibility "URL here" not only will the text show up, but so will the information for the element I'm searching for!

    No Errors, all text present

    As to what @Jimi mentioned in the comment, I believe this issue with persisting MSEdge processes when clicking on the X button only occurs if the MSEdge Performance Boost is enabled. I had found an article at some point, but with all the searching and frantic "Oh goodness no, I have to jump to Selenium?!?" moments I've had recently with trying to automate Edge, I've lost it in the swamp of my browser history. If I find it again, I'll post the link in this answer.

    If anyone has a better way of doing this very same thing outside of the flag, please, feel free to give some insights!