Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capybara cannot find date picker

Using capybara, I am trying to fill in a date. There is a javascript date picker on the form. I have tried the following ways to choose it:

find('input[type=date]').focus()
find(:xpath, ".//*[@id='Sdate']")
fill_in('Sdate', :with => '25/07/2555')

However for all of these attempts, I got the exact same error message:

Selenium::WebDriver::Error::UnknownError: '[JavaScript Error: "a is null" {file: "file:///var/folders/ky/r1ft86wd5x9cjq0f3f6tq0600000gn/T/webdriver-profile20120725-41019-m72bh5/extensions/[email protected]/components/command_processor.js" line: 5813}]' when calling method: [nsICommandProcessor::execute]

The html I am trying to fill in:

<input id="Sdate" type="text" readonly="" value="" size="10" name="Sdate">
<img align="absmiddle" onclick="return showCalendar('Sdate', 'dd/mm/yy');" style="cursor:pointer" src="../images/calendar_s.gif">

I am using Selenium webdriver on Firefox with Capybara 1.1.2 in a Rails 3.2.6 task.

What am I missing?

like image 538
Castielle Avatar asked Nov 19 '25 23:11

Castielle


1 Answers

I have the same setup and I was able to select box with this line:

select 'May', from: 'date_select_1'

where 'May' is a value which you want select from list and the *data_select_1* is ID of HTML tag from which you want select the value.

like image 195
Tom Hert Avatar answered Nov 21 '25 14:11

Tom Hert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!