Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoke Javascript event on control from C# web browser control

I am working on a web scraper in C# where I have a web browser control that loads a web page, I then collect data and depending on the data also acting on it. My problem is that I need to write some data to a input (textbox) that has listeners. The input control never shows a value in the html, it is handled by some Javascript that is fired from events on the control. I can set a value to the controls value parameter but it is as it is missing when I click OK on the form.

I have searched the web for days and I now know how to call Javascript from C# but it's the Javascript function on the input i cannot understand.

The input control looks like this:

<div id="size_1" class="incrementControl" style="width: 68px;">
    <input id="size_1-input" class="hasListeners" maxlength="6" tabindex="103" value="" style="width:52px">
    <a id="size_1-up" class="up hasListeners" style="left:52px" href="javascript:void(0)"> </a>
    <a id="size_1-down" class="down hasListeners" style="left:52px" href="javascript:void(0)"> </a>
</div>

The input controls event keyup, keydown, change, keypress and blur all call this Javascript:

function (a) 
{
    return typeof f != "undefined" && (!a || f.event.triggered !== a.type) ? f.event.dispatch.apply(i.elem, arguments) : b;
}

I have tried invoking different events like onClick and clicking the control programmatically but nothing works?! I don´t know how to call this Javascript function since it doesn't have a name and what to pass as a parameter?

Most grateful for any help or ideas!

like image 649
Johan Magnusson Avatar asked Oct 21 '12 00:10

Johan Magnusson


1 Answers

You can use Watin. It support Webbrowser control and Internet Explorer.

like image 107
Murat Topcu Avatar answered Oct 30 '22 05:10

Murat Topcu