0

I have opened a website using WebBrowser. Now I would like to programmatically click input text (textbox) field. I can not use focus because this website uses JS to unlock this field only if it's clicked and I've tried also this:

Object obj = ele.DomElement;
System.Reflection.MethodInfo mi = obj.GetType().GetMethod("click");
mi.Invoke(obj, new object[0]); 

But it returns mi = null. How to do this so it will work?

4 Answers 4

2

Very similar to my answer on your other question.

Get an HtmlElement respresentative of your textbox, and call HtmlElement.InvokeMember("click") on it.

Sign up to request clarification or add additional context in comments.

1 Comment

I don't have InvokeMethod only InvokeMember is it this?
1

If you can, use:

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

or something similar. For me, it's been much easier and more accurate.

Comments

1

To fill-up a text field on a webpage:

string code ="";
code = code + "var MyVar=document.getElementById('tbxFieldNameOnWebPage');if(MyVar != null) MyVar.value = 'SOMEVALUE';";
domDocument.parentWindow.execScript(code, "JScript");

Then To Click a button on a webpage:

code = "";
code = "var SignupFree = document.getElementsByTagName('button')[1];";
code = (code + " SignupFree.click();");
domDocument.parentWindow.execScript(code, "JScript");

you can also use document.getElementById('buttonID'); instead of document.getElementsByTagName('button')[1]; but an id must be provided for this button on that particular webpage.

Comments

0

Use InvokeMethhod on HtmlElement or Browser.InvokeScript function.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.