Cucumber Selenium web step to verify value of input field

I have an input field with an id which has a value. The web_steps.rb
method
does not find the value. Is this the right step to use to check an input
field? It works fine for a text_area but not an input.

Scenario steps (tried both ways):
Then the “travel_card_number_gate” field should contain “5”
Then the “#travel_card_number_gate” field should contain “5”

From web_steps.rb
Then /^the “([^”])" field(?: within “([^”])")? should contain
“([^”]*)"$/ do |field, selector, value|
with_scope(selector) do
field = find_field(field)
field_value = (field.tag_name == ‘textarea’) ? field.text :
field.value
if field_value.respond_to? :should
field_value.should =~ /#{value}/
else
assert_match(/#{value}/, field_value)
end
end
end

PS, this is the error message:

Then the "travel_card_number_gate" field should contain

“5” #
features/step_definitions/web_steps.rb:150
expected: /5/,
got: “” (using =~)
Diff:
@@ -1,2 +1 @@
-/5/
(RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/web_steps.rb:155:in block (2 levels) in <top (required)>' ./features/step_definitions/web_steps.rb:14:inwith_scope’
./features/step_definitions/web_steps.rb:151:in /^the "([^\"]*)" field(?: within "([^\"]*)")? should contain "([^\"]*)"$/' features/travel_card.feature:453:inThen the
“travel_card_number_gate” field should contain “5”’

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs