WebDriver - how to insert value to a hidden input field?

1,880 views
Skip to first unread message

Alex Lee

unread,
Sep 29, 2013, 8:17:07 AM9/29/13
to seleniu...@googlegroups.com
Hey guys,

I'm using WebDriver and coding in Python, and I'm stumped as to how to insert a date value into the 'Date' field of this site: http://matrix.itasoftware.com (multi-city tab, Flight 1).

I can get the ID of that specific date field (
ita_form_date_DateTextBox_0

), but any attempts to type a date there gets an 'ElementNotVisibleException' error message instead.

My code was:

flight_date = driver.find_element_by_xpath(".//*[@id='ita_form_date_DateTextBox_0']")
flight_date
.send_keys("01/27/2014")

Clicking on that Date field would reveal a calendar table, which I think would be even trickier to interact with.

However, on checking the code, when I type in the date, it inserts the value of the date on a hidden input field:

<input type="hidden" value="2014-01-07" sliceindex="0"/>

How would I insert the date value to a hidden input field?

Alasdair Collinson

unread,
Sep 30, 2013, 8:16:47 AM9/30/13
to seleniu...@googlegroups.com
I would think entering data into a hidden text box is difficult, but interacting with the calendar shouldn't be that tricky. To choose the given date I'd do something like this:
driver.findElement(By.xpath("//th[descendant::text()='Jan']")).click();
driver
.findElement(By.xpath("//table[class='
dijitReset dijitCalendarContainer'][./thead//td[text()='JANUARY 2014']]/tbody/tr/td/span[text()='27']")).click();
I haven't tested those xpaths mind you, but if they don't work something similar should.

tester

unread,
Oct 1, 2013, 8:22:44 PM10/1/13
to seleniu...@googlegroups.com
Selenium / webdriver is designed to interact with the web app, so you can not click or type keys into the hidden field. However you can run javascript to set values to the hidden field.

Reply all
Reply to author
Forward
0 new messages