[英]WebBrowser submit form, follow redirect, click URL, follow redirect automation
I'm trying to create a program that basically does the following: 我正在尝试创建一个基本上执行以下操作的程序:
So far I've tried using the event handler (DocumentCompleted) then access the form via wb.Document.Forms[0] and then using SetAttribute. 到目前为止,我已经尝试过使用事件处理程序(DocumentCompleted),然后通过wb.Document.Forms [0]访问该表单,然后使用SetAttribute。 That didn't work because I'm pretty much logging in so it only submitted the form (since that was under the DocumentCompleted event) at the end, after all the login info was loaded for multiple accounts (yes, I'm logging into multiple accounts). 那没有用,因为我几乎要登录,所以在所有登录信息都加载到多个帐户之后,它最后才提交表单(因为它在DocumentCompleted事件下)(是的,我正在登录多个帐户)。 Any ideas? 有任何想法吗? I'm lost. 我迷路了。 I've provided a basic example of what I tried, below. 我在下面提供了我尝试过的基本示例。 I haven't gotten as far as clicking the link on the next page because I have not yet been successful in logging in. At first I tried this with no eventhandler but then I realized it was needed or else web.Document always returned null. 由于尚未成功登录,我还没有点击下一页上的链接。一开始,我没有事件处理程序就尝试了此操作,但是后来我意识到这是必需的,否则web.Document始终返回null。 Then I tried adding the eventhandler in the foreach and the if statement in the function for the event. 然后,我尝试在foreach中添加事件处理程序,并在事件函数中添加if语句。 That as I said before only worked at the end and even after that I don't believe login was successful although I'm not 100% on that. 就像我之前所说的那样,直到最后,甚至在那之后,我都不相信登录成功,尽管我不是100%。
foreach(login in logins){
if (web.Document != null)
{
var form = web.Document.Forms[0];
var input = form.Children[0];
input.SetAttribute("value", "input value");
form.InvokeMember("submit");
}
}
I'm not sure whether you want to use it for testing or not but you can use Coded Ui Test for that. 我不确定您是否要使用它进行测试,但是可以使用编码的Ui测试。 You can record the actions and then generate code for that and then run it repeatedly after that. 您可以记录操作,然后为该操作生成代码,然后在此之后重复运行它。
http://msdn.microsoft.com/en-us/library/dd286726.aspx http://msdn.microsoft.com/en-us/library/dd286726.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.