【发布时间】:2011-06-01 05:03:23
【问题描述】:
我正在开发一个论坛的登录系统,并试图通过 c# .net 表单使其工作。我需要使用 webBrower 控件以编程方式单击论坛上的登录按钮。到目前为止,我有这个。
webPage page = new webPage();
page.URL = txtURL.Text;
page.Load(); //Load the text from the specified URL
WebBrowser browser = new WebBrowser();
browser.Document.GetElementById("navbar_username").SetAttribute("value", textBox1.Text);
browser.Document.GetElementById("navbar_password").SetAttribute("value", textBox2.Text);
HtmlElement el = browser.Document.All["btnI"];
if (el != null)
{
el.InvokeMember("click");
}
else
{
MessageBox.Show("There is an issue with the program");
}
问题是页面上的登录按钮没有 ID 或任何可以让我点击它的真实信息。有没有人有什么建议?这是登录按钮的代码。
<input type="image" src="images/loginbutton.png" class="loginbutton" tabindex="104" value="Log in" title="Enter your username and password in the boxes provided to login, or click the 'register' button to create a profile for yourself." accesskey="s">
【问题讨论】: