Right now when I run this it keeps clicking on the same button every 2 seconds. I’m trying to figure out how I can go on to the next ID rather than it keep doing the first one it finds then breaking. Here is my code:
private void button2_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
HtmlDocument doc = webBrowser1.Document;
HtmlElementCollection links = doc.GetElementsByTagName("a");
foreach (HtmlElement link in links)
{
if (link.GetAttribute("id").Contains("user"))
{
link.InvokeMember("click");
break;
}
}
}
Change your code to this…
By the way, I don’t know if HtmlElementCollection has a “Remove” method… if it doesn’t, simply use a generic List<> or an ArrayList, etc.