S
S
sivabur2015-04-27 22:11:16
C++ / C#
sivabur, 2015-04-27 22:11:16

How to simulate text input in the input field of the webBrowser1(c#,WinForms) element?

All options do not suit me ( they suit most of them ), the problem is that for each character input it is still written in a hidden field. The question is how to actually simulate the input? replacing the value attribute will not work. There is one button and webBrowser1 element on the form.
Climbed the whole Google, stekofreflov nothing sensible.

private void button1_Click(object sender, EventArgs e) 
{ 
    webBrowser1.Navigate("http://www.defense.gov"); 
}
 private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
 { 
    1-вариант //webBrowser1.Document.GetElementById("id_inputa").InvokeMember("click");
    //SendKeys.SendWait("123");

    2-вариант //webBrowser1.Document.GetElementById("id_inputa").Focus();
    //SendKeys.SendWait("123");

    3-вариант //webBrowser1.Document.GetElementById("id_inputa").InnerText="123";

    4-вариант //webBrowser1.Document.GetElementById("id_inputa").SetAttribute("value", "123");
 }

Solutions:
webBrowser1.Document.GetElementById("id_inputa").InvokeMember("focus");
SendKeys.SendWait("123");

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question