c# - 无法指示密码字段的 html id 并且无法使用 Win Forms 登录页面
问题描述
尝试使用 WinForms 和 C# 登录到 Intranet 站点。
以下是登录代码 -
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">
解决方案
推荐阅读
- jquery - 无法访问 DataTables 实例
- python - 如何按照 list(aList) 的原始出现顺序获取 list(set(aList)) 值?
- javascript - 禁用 Chrome 网络安全后仍然强制执行 CORS?
- sql - DB2 SQL 语句 - 是否可以 A) 声明一个临时表 B) 用数据填充它然后 C) 对它运行一个 select 语句?
- python - 如何仅在表格的名称列中添加名称?
- ios - 选择文本字段时如何滚动 UITableView
- amazon-web-services - 是否可以丰富 sqs 队列上的消息
- node.js - 完全失去了承诺异步/等待
- reporting-services - SSRS:添加具有多行描述的列标题
- c# - 将自定义模型绑定器应用于 asp.net 核心中的对象属性