使用WebBrowser控件以编程方式登录到网站时出现问题

编程入门 行业动态 更新时间:2024-10-18 08:34:07
本文介绍了使用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控件以编程方式登录到网站时出现问题

本文发布于:2023-11-23 20:37:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622794.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   方式   网站   WebBrowser

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!