Class: GovukRSpecHelpers::ClickButton
- Inherits:
-
Object
- Object
- GovukRSpecHelpers::ClickButton
- Defined in:
- lib/click_govuk_button.rb
Instance Attribute Summary collapse
-
#button_text ⇒ Object
readonly
Returns the value of attribute button_text.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
- #click ⇒ Object
-
#initialize(page:, button_text:, disabled: false) ⇒ ClickButton
constructor
A new instance of ClickButton.
Constructor Details
#initialize(page:, button_text:, disabled: false) ⇒ ClickButton
Returns a new instance of ClickButton.
6 7 8 9 10 |
# File 'lib/click_govuk_button.rb', line 6 def initialize(page:, button_text:, disabled: false) @page = page @button_text = @disabled = disabled end |
Instance Attribute Details
#button_text ⇒ Object (readonly)
Returns the value of attribute button_text.
4 5 6 |
# File 'lib/click_govuk_button.rb', line 4 def @button_text end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
4 5 6 |
# File 'lib/click_govuk_button.rb', line 4 def disabled @disabled end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
4 5 6 |
# File 'lib/click_govuk_button.rb', line 4 def page @page end |
Instance Method Details
#click ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/click_govuk_button.rb', line 12 def click @buttons = page.all('button', text: , exact_text: true) if @buttons.empty? @buttons = page.all('a.govuk-button', text: , exact_text: true) end if @buttons.empty? @buttons = page.all("input[type=submit][value=\"#{Capybara::Selector::CSS.escape()}\"]") end if @buttons.size == 0 check_for_inexact_match raise "Unable to find button \"#{}\"" end @button = @buttons.first check_data_module_attribute_is_present check_for_govuk_class @button.click unless disabled end |