Pergunta

I have a winform which loads flashscore.com in a geckofx browser. i Have added a button which i want to simulate a click in the page. I want to click the calendar which you select the date. This event is

`<a href="#" onclick="display_hide('ifmenu-calendar-content'); e_t.track_click('iframe-bookmark-click', 'calendar'); return false;"><i></i>13/03 Th</a>`

Is there a way i can fire this onclick event by my button?

Thank you

Foi útil?

Solução

This is C# syntax (sorry don't know vb)

The first thing you have to do is locate the Element you want to click.

If the Element has an Id you can do it with something like this:

var element = browser.Document.GetElementById("someid");

If the element doesn't have a id then you have to locate it a different way. One of many possible options is to get all the elements of that tag a and loop over them until you find the one you want.

GeckoHtmlElement element = null;
var elements = browser.Document.GetElementsByName("a");
foreach(var e in elements)
{

 if (/*Test if e if the element you are after)
   element = e;
}

Once you have located the element you can just call click on that element.

element.Click();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top