0

I've got this little collection of all the Inputs on the loaded site. The program searches for a text input that is specified by a list of html names

GeckoElementCollection _Ellements = geckoWebBrowser1.Document.GetElementsByTagName("input");

The Problem is that it wont fill the textbox

foreach (GeckoElement _e in _Ellements)
{
    if (_e.GetAttribute("value") == "username")
    {
        _e.SetAttribute("selected", "Username Here");
    }
}

Please help me I've been trying to fix this for ages

Merceyz
  • 25
  • 1
  • 3
  • 12

2 Answers2

1

Here is some example code that sets the value of all inputs then document has finished loading.

Of course 'inputs' can be of different types (like Buttons, Text boxes, radio buttons) so in you would want to check the the type attribute as well.

browser.DocumentCompleted += (s, e) =>
{

 GeckoElementCollection elements = browser.Document.GetElementsByTagName("input");
 foreach (var element in elements)
 {
  GeckoInputElement input = (GeckoInputElement) element;
  input.Value = "Auto filled!";
 }
};
Tom
  • 6,325
  • 4
  • 31
  • 55
0

this is my solution:

web.DocumentCompleted += (s, e) =>
{
    GeckoInputElement elms = web.DomDocument.GetElementsByTagName("input")
    foreach (elm in elms )
    {
        if (elm.GetAttribute("id") = "search") 
        {
            elm.Value = "itvlog";
            break;
        }
    }
};
Dũng IT
  • 2,751
  • 30
  • 29