Skip to content

Commit

Permalink
Create custom method to handle selection of new GOVUK radio/checkboxes
Browse files Browse the repository at this point in the history
- input is no longer clickable through Capybara with new style
  radio/checkboxes as they have opacity: 0
- these methods use trigger('click') to hit the labels
  associated with the inputs
- corrected other SitePrism objects to inherit from 'Page'
  object to be consistent with others
  • Loading branch information
Guntrisoft committed Dec 5, 2016
1 parent 99901b4 commit 3f27a1b
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion features/pages/booking_complete.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Pages
class BookingComplete < SitePrism::Page
class BookingComplete < Page
set_url '/locations/{id}/booking-request/complete'

element :error, '.t-errors'
Expand Down
2 changes: 1 addition & 1 deletion features/pages/booking_confirmation.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Pages
class BookingConfirmation < SitePrism::Page
class BookingConfirmation < Page
set_url '/locations/{id}/booking-request/completed'
end
end
2 changes: 1 addition & 1 deletion features/pages/booking_ineligible.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Pages
class BookingIneligible < SitePrism::Page
class BookingIneligible < Page
set_url '/locations/{id}/booking-request/ineligible'
end
end
2 changes: 1 addition & 1 deletion features/pages/booking_step_one.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative '../sections/feedback'

module Pages
class BookingStepOne < SitePrism::Page
class BookingStepOne < Page
set_url '/locations/{id}/booking-request/step-one'

element :location_name, '.t-location-name'
Expand Down
2 changes: 1 addition & 1 deletion features/pages/booking_step_two.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Pages
class BookingStepTwo < SitePrism::Page
class BookingStepTwo < Page
set_url '/locations/{id}/booking-request/step-two'

element :error, '.t-errors'
Expand Down
2 changes: 1 addition & 1 deletion features/pages/feedback_page.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative '../sections/feedback'

module Pages
class Feedback < SitePrism::Page
class Feedback < Page
set_url '/feedback/new'

section :feedback, Sections::Feedback, '.t-feedback'
Expand Down
12 changes: 12 additions & 0 deletions features/pages/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,17 @@ class Page < SitePrism::Page
elements :link_promo_items, '.t-link-promo__item'

section :footer, Sections::Footer, '#footer'

def check_hidden_checkbox(element, check)
input = element.find('input[type=checkbox]')
input.trigger('click') if input['checked'] != check

raise 'value did not change' if input['checked'] != check
end

def check_hidden_radio(element)
input = element.find('input[type=radio]')
input.trigger('click')
end
end
end
7 changes: 3 additions & 4 deletions features/step_definitions/customer_booking_request_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,15 @@
@step_two.email.set '[email protected]'
@step_two.telephone_number.set '07715 930 459'
@step_two.memorable_word.set 'birdperson'
@step_two.accessibility_requirements.set false
@step_two.opt_in.set true
@step_two.check_hidden_checkbox(@step_two.accessibility_requirements, true)
@step_two.check_hidden_checkbox(@step_two.opt_in, true)
end

When(/^I pass the basic eligibility requirements$/) do
@step_two.date_of_birth_day.set '01'
@step_two.date_of_birth_month.set '01'
@step_two.date_of_birth_year.set '1950'

@step_two.dc_pot_yes.set true
@step_two.check_hidden_radio(@step_two.dc_pot_yes)
end

When(/^I submit my completed Booking Request$/) do
Expand Down

0 comments on commit 3f27a1b

Please sign in to comment.