Skip to content

Commit 933bd61

Browse files
committed
fix random crash when clicking datepicker
1 parent 938df13 commit 933bd61

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/capybara-bootstrap-datepicker.rb

+10-5
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,16 @@ def select_date(value, options = {})
4343

4444
datepicker_years.find('.year', text: date.year).click
4545
datepicker_months.find('.month', text: date.strftime("%b")).click
46-
day_xpath = ".//*[contains(concat(' ', @class, ' '), ' day ') \
47-
and not(contains(concat(' ', @class, ' '), ' old ')) \
48-
and not(contains(concat(' ', @class, ' '), ' new ')) \
49-
and normalize-space(text())='#{date.day}']"
50-
datepicker_days.find(:xpath, day_xpath).click
46+
day_xpath = <<-eos
47+
.//*[contains(concat(' ', @class, ' '), ' day ')
48+
and not(contains(concat(' ', @class, ' '), ' old '))
49+
and not(contains(concat(' ', @class, ' '), ' new '))
50+
and normalize-space(text())='#{date.day}']
51+
eos
52+
datepicker_days.find(:xpath, day_xpath).trigger :click
53+
54+
expect(Date.parse date_input.value).to eq date
55+
expect(page).to have_no_css '.datepicker'
5156
when :jquery
5257
raise "jQuery UI datepicker support is not implemented."
5358
else

0 commit comments

Comments
 (0)