0

There are a bunch of websites with "search" input boxes.
If I input a word manually then it automatically search without need to click any buttons.

Using the following code:

             GeckoInputElement input = (GeckoInputElement)geckoHtmlElement;
             input.Value = "searchword";

The I see that search input box is filled but nothing happens automatically.
If I manually add space or any character then website works as expected.
Auto searches my wanted word.

I tried using input.Focus(); but still same.
Any ideas how I can input text into search box in a more advanced way or something like that?

Scott Solmer
  • 3,871
  • 6
  • 44
  • 72
Aasas
  • 51
  • 2
  • 8
  • You appear to be using serverside code to fill the element. The code needed for doing this kind of stuff has to be on the clientside – Carlos Muñoz Oct 10 '14 at 13:53
  • Yeah, I thought about that. Didnt knew how to explain. Any idea how to make it clientise that It could work as I input text manually? – Aasas Oct 10 '14 at 13:54
  • Perhaps causing a "blur" will work. Either call it directly, or move the focus elsewhere to force a blur event. This may be of use: http://stackoverflow.com/questions/5212651/blur-vs-onblur – John Hatton Oct 10 '14 at 15:17
  • aHH I'm not sure if you understood what Im asking for. Im making automation on geckofx browser and I need way to input text fields proper way which would trigger any javascripts or something which are on that webpage – Aasas Oct 10 '14 at 15:20

1 Answers1

2

I think the solution here is to manually trigger the event that triggers the search - for example the keyup event. I had the same problem which I solved by adding this code:

    nsAStringBase eventType = (nsAStringBase)new nsAString("keyup");
            var ev = browser.Document.CreateEvent("HTMLEvents");
            ev.DomEvent.InitEvent(eventType, false, false);
nameBox.GetEventTarget().DispatchEvent(ev);

You would need to inspect your page and see if there are any javascript events attached to your input. Good luck!

Bartosz
  • 4,406
  • 7
  • 41
  • 80