I have WPF application on Visual Studio 2015. I have a button, I click the button, it opens an instance of IE, it navigates to a page, it fills in username and password, it click "sign in", it displays a message "I'm here", then I click an "OK"-button on that message box and it goes in a loop to do it from the beginning. When I try to find the element where I input the username, the program crashes, saying:
System.Reflection.TargetInvocationException occurred
HResult=-2146232828
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
InnerException:
HResult=-2146827850
Message=Exception from HRESULT: 0x800A01B6
Source=""
InnerException:
And the key point here is that it doesn't do it on the first time.