Change Default Web Browser
Has anyone scripted a way to change the default web browser in Windows10 during a test run? I am able to open the Default apps window, but can't access the various browser options by name, only through keyboard strokes (ie [Tab] and [Enter]), which won't work as it seems the order of the browsers can vary from one machine to another.
I've been using Object Browser and Spy Tool to try to figure out what I need to add to my project's UI Automation list of accepted windows (at least I think this is what I need to do) but haven't come across the correct combination yet.
This is my initial JavaScript function that works, but relies on the browser options being in a specific order:
function TESTsetDefaultBrowser(){ Sys.Desktop.Keys("[Win]choose a default web browser"); Sys.Desktop.Keys("[Enter]"); Aliases.WaitAliasChild("ApplicationFrameHost"); // select web browser Sys.Desktop.Keys("[Enter]"); Delay(1000); // tab to desired browser Sys.Desktop.Keys("[Tab][Tab][Enter]"); }
I want to replace the last line with something like Object.ClickItem("Chrome");
Here's the Default Apps window in the Object Browser:
And here's the items I've added to the project's list of UIAutomation accepted windows:
Any insight is appreciated. Thanks!
After much research I came across these two programs to set the default browser programatically for the current user. It seems that it has become a lot less simple than it used to be thanks to a hash that is now a part of the registry editor in recent versions of Windows 10.