views:

655

answers:

4

Theres a link i want to click. I also have the HtmlElement of the link. However it is /site/blah/# so i know theres some JS there. How do i simulate the click?

+2  A: 

All DOM elements have a click() method - have you tried calling that?

belugabob
all i see is an event which i cant call.
acidzombie24
+2  A: 

You should be able to just call the click() method

<script type="text/javascript">

    element = document.getElementById('thelinkid'); //or whatever other method you used to get the element
    element.click();
</script>
monkey_p
A: 

childElement.RaiseEvent("OnClick");

acidzombie24
+1  A: 

Maybe not the prettiest but this has worked best for me:

webbrowser1.Navigate("javascript:document.forms[0].submit()")

Similarly you can fill out forms, remove elements, etc.

Eyal