hi i want to get URL from browsers and for chrome i used these and the is not working getting null exception i think chrome has changed something.. getting error on elm4
I solved the same problem recently with System.Windows.Forms.SendKeys Compared to your result - it's 4 times faster, but doesn't work with websites which use ctrl+l hotkey (for example StackOwerflow in edit mode). Depends on your needs :)
public void WithSendkeys()
{
AutomationElement.RootElement
.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ClassNameProperty, "Chrome_WidgetWin_1"))
.SetFocus();
SendKeys.SendWait("^l");
var elmUrlBar = AutomationElement.FocusedElement;
var valuePattern = (ValuePattern) elmUrlBar.GetCurrentPattern(ValuePattern.Pattern);
Console.WriteLine(valuePattern.Current.Value);
}