Unable to indicate the html id for password field and not able to login to the page using Win Forms

0

enter image description hereTrying to login to an Intranet site using WinForms and C#.

Following is the code for login -

webbrowserObject.Document.GetElementById("USER").SetAttribute("value", Properties.Settings.Default.UserEmail);
webbrowserObject.Document.GetType("password").SetAttribute("Value", Properties.Settings.Default.UserPassword);
webbrowserObject.Document.GetElementById("loginbtn").InvokeMember("submit");

Getting following error -

Severity    Code    Description Project Path    File    Line    Suppression State
Error   CS1501  No overload for method 'GetType' takes 1 arguments

And when I am changing the code as below -

 webbrowserObject.Document.GetElementById("USER").SetAttribute("value", Properties.Settings.Default.UserEmail);
 webbrowserObject.Document.GetElementById("PASSWORD").SetAttribute("Value", Properties.Settings.Default.UserPassword);
 webbrowserObject.Document.GetElementById("loginbtn").InvokeMember("submit");
 while (!DocumentLoaded)

Following is the error -

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

Following are the html information of the Site that I am trying to login to -

<input name="USER" class="form-control textbox center-block noborder " id="USER" autofocus="" required="" type="text" placeholder="User ID">
<input name="PASSWORD" class="form-control textbox  center-block noborder" required="" onkeydown="return FormKeyPressed();" type="password" placeholder="Password">
c#
winforms
asked on Stack Overflow Oct 11, 2019 by Anurag Thakur • edited Oct 14, 2019 by Anurag Thakur

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0