Please quote previous message when replying, otherwise it is difficult
to follow the thread. Thanks.
I suggest you contact the site owner and tell him/her you are having
difficulty scraping his page and ask him to correct the html to make
your life easier.
Feature:
Scenario: home page
Given....
..
When I choose "TestClientA"
.....
Then..
Step: I am using auto generated - choose in web_steps.rb
When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field,
selector>
with_scope(selector) do
choose(field)
end
end
This is not working either in default capybara driver or selenium
driver.
(: failed steps (:
cannot choose field, no radio button with id, name, or label
'TestClientA' found (Capybara::ElementNotFound)
./features/step_definitions/web_steps.rb:90
./features/step_definitions/web_steps.rb:14:in `with_scope'
./features/step_definitions/web_steps.rb:89:in `/^(?:|I )choose
"([^"]*)"(?: within "([^"]*)")?$/'
features\login.feature:17:in `When I choose "TestClientA"'
I tried xpath, but that is working only with selenium driver, not with
capybara default driver. Any ideas?
When I choose "TestClientA"
cannot choose field, no radio button with id, name, or label
'TestClientA' found (Capybara::ElementNotFound)
./features/step_definitions/web_steps.rb:90
./features/step_definitions/web_steps.rb:14:in `with_scope'
./features/step_definitions/web_steps.rb:89:in `/^(?:|I )choose
"([^"]*)"(?: within "([^"]*)")?$/'
features\login.feature:17:in `When I choose "TestClientA"'
TestClientA is not an id, name nor label, that's why capybara can't find
it.
In your case, all radio buttons have unique ids (which is the way it
should be). Choose the button based on the id, in your case:
"current_client_id_3" (for TestClientA).
Error: cannot choose field, no radio button with id, name, or label
'current_client_id_3' found (Capybara::ElementNotFound)
./features/step_definitions/web_steps.rb:90
./features/step_definitions/web_steps.rb:14:in `with_scope'
./features/step_definitions/web_steps.rb:89:in `/^(?:|I )choose
"([^"]*)"(?: within "([^"]*)")?$/'
features\login.feature:16:in `And I choose "current_client_id_3"'
Got the same error with unmodified html code as well
b) When I choose "TestClientA"
Error:cannot choose field, no radio button with id, name, or label
'TestClientA' found (Capybara::ElementNotFound)
./features/step_definitions/web_steps.rb:90
./features/step_definitions/web_steps.rb:14:in `with_scope'
./features/step_definitions/web_steps.rb:89:in `/^(?:|I )choose
"([^"]*)"(?: within "([^"]*)")?$/'
features\login.feature:16:in `When I choose "TestClientA"'
Here's one thing to fix. The 'for' attribute of a label must equal the ID of the form element (if it exists) or the name attribute of the form element if the ID does not exist. So in your example, the code should be: