我一直在尝试从我的 c# 表单中输入数据,当我单击表单上的提交按钮时,它应该被转移到TextBox
网站...这里
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Document.All.GetElementsByName("email")[1].SetAttribute("Value", textBox2.Text);
webBrowser1.Document.All.GetElementsByName("pass")[1].SetAttribute("Value", textBox3.Text);
webBrowser1.Document.GetElementsByTagName("form")[1].InvokeMember("submit");
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("gmail.com");//Your link
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
我所做的是在网络浏览器中打开一个链接并搜索属性以在其中输入数据,但它给出了一个错误,"Value of '1' is not valid for 'index'. 'index' should be between 0 and -1."
当我将索引更改为零时它给出了同样的错误。