I have tried the following method to get the URL, but it is only working for windows default Edge browser, not working in updated version of Edge Browser(Ver : 83.0). I'm using this browser : https://www.microsoft.com/en-us/edge
public static string GetEdgeUrl(Process process)
{
try
{
if (process == null)
throw new ArgumentNullException("process");
if (process.MainWindowHandle == IntPtr.Zero)
return null;
AutomationElement main = AutomationElement.FromHandle(process.MainWindowHandle);
if (main == null) // not edge
return null;
AutomationElement window = main.FindFirst(TreeScope.Children, new AndCondition(
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window),
new PropertyCondition(AutomationElement.NameProperty, "Microsoft Edge")));
if (window == null) // not edge
return null;
var adressEditBox = window.FindFirst(TreeScope.Children,
new PropertyCondition(AutomationElement.AutomationIdProperty, "addressEditBox"));
return ((TextPattern)adressEditBox.GetCurrentPattern(TextPattern.Pattern)).DocumentRange.GetText(int.MaxValue);
}
catch (Exception ex)
{
throw ex;
}
}