InvokeMember("click") webBrowser help

Posted by Tom on Stack Overflow See other posts from Stack Overflow or by Tom
Published on 2010-04-16T16:05:48Z Indexed on 2010/04/16 16:23 UTC
Read the original article Hit count: 627

Filed under:
|
|

I am trying to automate a web page via the weBrowser and the button that i'm trying to click has no ID only a value. here's the html code for it:

Accept

I can't useGetElementById as the button has no ID. If I do

HtmlElement goButton = this.webBrowser1.Document.All["Accept"];
goButton.InvokeMember("click");

My script stops showing a nullreference error highlighting the "goButton.InvokeMember("click");"
If I do

var inputControls = (from HtmlElement element in webBrowser1.Document.GetElementsByTagName("input") select element).ToList();
                HtmlElement submitButton = inputControls.First(x => x.Name == "Accept");

My script give me an "Sequence contains no matching element" error at the "HtmlElement submitButton" line and sometimes the page has more than one of these Accept buttons, so I would need to be able to tell the difference between each one as well or at least be able to click on one without the script breaking

Any help with this will be greatly appreciated

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET