本文介绍了使用WebBrowser控件以编程方式登录到网站时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图以编程方式登录 到" www. salesgenie/Account/LogOn 使用WebBrwoser控件. 问题是当我单击登录"时,浏览器无法导航到LogonCompleted事件中的下一页.
Hi, I''m trying to login programatically to "www.salesgenie/Account/LogOn" using WebBrwoser control. The problem is when I click on "Log On", the browser doesn''t navigate to the next page in the LogonCompleted event.
HtmlElement userName = wBrowser.Document.GetElementById("username"); userName.SetAttribute("value", SomeUserName); HtmlElement password = wBrowser.Document.GetElementById("password"); password.SetAttribute("value", SomePassword); wBrowser.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(LogonPageLoaded); wBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(LogonCompleted); HtmlElement logonForm = wBrowser.Document.GetElementById("logon-submit"); logonForm.InvokeMember("click");我认为这是因为元素"logon-submit"调用了一个JavaScript函数左右. 请提供任何帮助.
I think this is because the element "logon-submit" calls a JavaScript function or so. Please, any help would be appreciated.
推荐答案使用Fiddler [ ^ ]来确定该站点在做什么.这就是我在这种情况下要做的. Use Fiddler [^] to figure out what the site is doing. That''s what I do in a case like this.
更多推荐
使用WebBrowser控件以编程方式登录到网站时出现问题
发布评论