Невозможно указать html id для поля пароля и не удается войти на страницу с помощью Win Forms - PullRequest
0 голосов
/ 11 октября 2019

enter image description here Попытка войти на сайт интрасети с использованием WinForms и C #.

Ниже приведен код для входа в систему -

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");

Получение следующей ошибки -

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

И когда я изменяю код, как показано ниже -

 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)

Ниже следует ошибка -

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>

Ниже приведены html-данныесайта, на который я пытаюсь войти -

<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">
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...