向网站上的密码字段发送/设置值 [英] Sending/Setting a value to a Password Field on a Website
问题描述
我编写了一个小应用程序,该应用程序需要登录网站才能执行某些操作. 问题是,每当我尝试在网站上设置密码字段时,它都不接受密码.
I have written a small application that needs to log in to a website to perform some actions. The problem is that whenever I try to set the password field on the website it doesn't accept the password.
我已经找到通过使用SendKeys函数解决此问题的方法.这样做的问题是它需要集中精力并且程序需要在后台运行.
I have found a way around this by using the SendKeys function. The problem with that is that it requires focus and the program requires to run in the background.
有没有办法做到这一点?
Is there a way to do this?
以下是如何设置用户名字段的示例:
Here is an example of how you'd set the Username Field:
WebBrowser.Document.GetElementById("field-username").SetAttribute("value", "UserName")
任何帮助都会很棒.
推荐答案
此问题的答案如下:
WebBrowser.Document.GetElementById("field-loginFormPassword").SetAttribute("maxLength", "20")
WebBrowser.Document.GetElementById("field-loginFormPassword").SetAttribute("value", "yourpassword")
通过更改最大长度"值,可以将值"设置为所需的文本,然后可以提交表单,它将接受它.
By changing the "maxlength" value it allows you to set the "value" to the desired text and then you can submit the Form and it will accept it.
这篇关于向网站上的密码字段发送/设置值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!