VB.NET Web浏览器单击按钮
我正在一个小型 VB.NET 项目工作,该项目自动填充雅虎注册页面上的字段。有没有办法点击“检查”按钮来查看输入的ID是否正确?
例如,如果输入的 ID 正确,则继续填写该字段,如果不正确,请尝试另一个 ID,然后再次按“检查”按钮。
I am working at a small VB.NET project which autofill the fields on the Yahoo register page. Is there a way to click on "Check" button and see if the entered ID is OK or not?
Something like if the entered ID is OK then proceed further with filling the field, if not, try another ID and press "Check" button again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Webbrowser 控件允许您访问网页中的元素,并且可以调用它们的方法,因此像这样简单的操作将单击按钮:
The webbrowser control lets you access elements within the webpage and you can invoke methods on them, so something as simple as this will click the button:
向您的应用程序添加一个定时器,间隔为 1000 毫秒。下面是代码:
Handles WebBrowser1.DocumentCompleted
我添加了一个计时器,因为浏览器在 WebBrowser1_DocumentCompleted 方法中似乎没有验证 Enter 键。
通过这段代码,你可以知道你输入的id是否正确。它并不完整,但它是一个好的开始,尝试理解它并根据您的需求进行调整。
Add a timer to your application, with an interval of 1000 ms. Here is the code:
Handles WebBrowser1.DocumentCompleted
I added a timer because the browser doesn't seem to validate the Enter key while in the WebBrowser1_DocumentCompleted method.
With this code, you can know if the id you entered is OK or not. It is not complete, but it's a good beginning, try to understand and adapt it for your needs.