I am trying to randomly Click/Navigate to a URL in my browser after the page is finished loading. I'm fairly new to C# and GeckoFX, I'm guessing the steps should be;
So far I can get the urls but I dont know what to do next;
private void LoadingFinished(object sender, EventArgs args)
{
foreach (GeckoElement htmlElement in geckoWebBrowser1.Document.Links)
{
string linkItem = htmlElement.GetAttribute("href").ToString();
}
}
You could try the following
var links = new List<GeckoElement>()
foreach(var link in browser.Document.Links) {
if(!String.IsNullOrEmpty(link.GetAttribute("href").ToString()))
links.Add(link);
}
if(links.Count > 0)
((GeckoHtmlElement)links[new Random().Next(0, links.Count)]).Click()
else
MessageBox.Show("No Links found")