Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我写了一个小应用程序,它需要登录到一个网站来执行一些操作。问题是,每当我尝试在网站上设置密码字段时,它都不接受密码。
我通过使用 SendKeys 函数找到了解决此问题的方法。问题在于它需要焦点并且程序需要在后台运行。
有没有办法做到这一点?
以下是如何设置用户名字段的示例:
WebBrowser.Document.GetElementById("field-username").SetAttribute("value", "UserName")
任何帮助都会很棒。
这个问题的答案如下:
WebBrowser.Document.GetElementById("field-loginFormPassword").SetAttribute("maxLength", "20") WebBrowser.Document.GetElementById("field-loginFormPassword").SetAttribute("value", "yourpassword")
通过更改“maxlength”值,您可以将“值”设置为所需的文本,然后您可以提交表单,它会接受它。
尝试使用mshtml或Html 敏捷包