3

I am trying to login to a website. I am able to fill out the form correctly with all of the connection information, but I cannot get the page to login. The button is a link without a name or id, so I can't click it directly. I have been working on invokeScript() stuff, but that doesn't seem to work either. This is the button code:

<div style="float:left; width:50px; margin: 0px auto 0px auto; text-align:center;">
    <div id="loginBtn">
        <a href="#" style="text-decoration:none; font-weight:bold; font-size: 10px; color:#FFFFFF;" onClick="javascript: LoginSubmit(event, true);" tabindex="3">
            Log In
        </a>
    </div>
</div>

How can I click a link like that?

I have tried stuff like this:

webBrowserControl.InvokeScript("LoginSubmit", "true" );

webBrowserControl.InvokeScript("LoginSubmit(event, true)"); 

and

webBrowserControl.InvokeScript("LoginSubmit", new object[] { new string[] { "event", "true" } });
Nathan Tornquist
  • 6,468
  • 10
  • 47
  • 72

1 Answers1

3

You may be missing Document, like so:

webBrowserControl.Document.InvokeScript(name, args)

if not try invoking the script with this wrapper method, extract:

private object MyInvokeScript(string name, params object[] args) 
{ 
    return webBrowserControl.Document.InvokeScript(name, args); 
}

…

int x = 50; 
int y = 100; 
MyInvokeScript("LoginSubmit",x, y);
m.edmondson
  • 30,382
  • 27
  • 123
  • 206