Search code examples
winformsfillgeckofx

Autofill date in textbox in geckofx


I've been trying to fill some textboxes in geckofx 22.0.7. Most of them with success. There are a couple though that resist any change! Both of them allow only numbers to be typed.
The first one (the one presented here) is used to receive a date entry. The user only types numbers (not slashes or dashes etc). The html code follows:

<td class=" dataEntryCol4">
<input id="insertDate" class="ui-inputfield ui-inputmask ui-widget ui-state-default ui-corner-all" type="text" style="width:90px" tabindex="2" value="" name="insertDate" role="textbox" aria-disabled="false" aria-readonly="false" aria-multiline="false">
</td>

My code is this:

GeckoHtmlElement insertDate = document.GetHtmlElementById("insertDate");
insertDate.SetAttribute("value", "08/06/2014");

I also tried using

SendKeys.SendWait("08062014"); 
SendKeys.SendWait("{TAB}");

I can't get it to work. Any suggestions?


Solution

  • First cast GeckoHtmlElement to a GeckoInputElement then use the Value property.

    GeckoInputElement insertDate = (GeckoInputElement)document.GetHtmlElementById("insertDate");
    insertDate.Value = "08/06/2014";