How do I select a radio button when both id and name are identical?: <input type="radio" name="BILFPB.bilPremieUppgifterFI.under24" tabindex="13" value="J24" checked="checked" id="forare">Ja <input type="radio" name="BILFPB.bilPremieUppgifterFI.under24" tabindex="14" value="N24" id="forare">Nej Normally I use choose.(''A radio button''), but that doesn''t seem to work with values. Any ideas? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Short answer is the IDs should be unique. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 16 December 2010 13:52, Sofie Willander <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> How do I select a radio button when both id and name are identical?: > > <input type="radio" name="BILFPB.bilPremieUppgifterFI.under24" > tabindex="13" value="J24" checked="checked" id="forare">Ja > <input type="radio" name="BILFPB.bilPremieUppgifterFI.under24" > tabindex="14" value="N24" id="forare">NejI believe that is not valid html unless id values are unique. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I have not written that code.. It''s on a webpage that I''m trying to screen scrape.. Does it mean that I can''t change selected button with Capybara? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 16 December 2010 14:06, Sofie Willander <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have not written that code.. It''s on a webpage that I''m trying to > screen scrape..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. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote in post #968844:> On 16 December 2010 13:52, Sofie Willander <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> How do I select a radio button when both id and name are identical?: >> >> <input type="radio" name="BILFPB.bilPremieUppgifterFI.under24" >> tabindex="13" value="J24" checked="checked" id="forare">Ja >> <input type="radio" name="BILFPB.bilPremieUppgifterFI.under24" >> tabindex="14" value="N24" id="forare">Nej > > I believe that is not valid html unless id values are unique.You are correct. But you could probably still use CSS or XPath selectors to get the item you want.> > ColinBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I am having a similar issue. HTML: <li> <label> <input id="current_client_id_2" name="current_client_id" value="2" type="radio">Test client 2 </label> </li> <li> <label> <input id="current_client_id_4" name="current_client_id" value="4" type="radio"> Test client 2 </label> </li> <li> <label> <input id="current_client_id_3" name="current_client_id" value="3" type="radio"> TestClientA </label> </li> 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? On Dec 16, 10:06 am, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #968844: > > > On 16 December 2010 13:52, Sofie Willander <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> How do I select a radio button when both id and name are identical?: > > >> <input type="radio" name="BILFPB.bilPremieUppgifterFI.under24" > >> tabindex="13" value="J24" checked="checked" id="forare">Ja > >> <input type="radio" name="BILFPB.bilPremieUppgifterFI.under24" > >> tabindex="14" value="N24" id="forare">Nej > > > I believe that is not valid html unless id values are unique. > > You are correct. But you could probably still use CSS or XPath > selectors to get the item you want. > > > > > Colin > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> <input id="current_client_id_3" name="current_client_id" > value="3" type="radio"> > TestClientA > </label> > </li>> 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). -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 17, 2010, at 6:19 PM, pingu wrote:> I am having a similar issue. > > > HTML: > <li> > <label> <input id="current_client_id_2" > name="current_client_id" value="2" type="radio">Test client 2 > </label> > </li> > <li> > <label> > > <input id="current_client_id_4" name="current_client_id" > value="4" type="radio"> > Test client 2 > </label> > </li> > <li> > <label> > <input id="current_client_id_3" name="current_client_id" > value="3" type="radio"> > TestClientA > </label> > </li> >Do what the other poster suggested or change your HTML to this... <input id="current_client_id_3" name="current_client_id" value="3" type="radio"> <label for="current_client_id_3">TestClientA</label> Then your ''When I choose'' should work.> > 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?-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sofie/Philip - Thanks for your suggestions. I tried both the approaches, but no luck. HTML: <li> <input id="current_client_id_3" name="current_client_id" value="3" type="radio"> <label for="TestClientA"> TestClientA</label> </li> Corresponding haml(just in case) %li = radio_button_tag "current_client_id", client.id %label{:for => client.client_name}=client.client_name a) When I choose "current_client_id_3" 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"'' Rails: 2.3.5, Ruby:ruby 1.8.7 On Dec 18, 12:35 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote:> On Dec 17, 2010, at 6:19 PM, pingu wrote: > > > > > I am having a similar issue. > > > HTML: > > <li> > > <label> <input id="current_client_id_2" > > name="current_client_id" value="2" type="radio">Test client 2 > > </label> > > </li> > > <li> > > <label> > > > <input id="current_client_id_4" name="current_client_id" > > value="4" type="radio"> > > Test client 2 > > </label> > > </li> > > <li> > > <label> > > <input id="current_client_id_3" name="current_client_id" > > value="3" type="radio"> > > TestClientA > > </label> > > </li> > > Do what the other poster suggested or change your HTML to this... > > <input id="current_client_id_3" name="current_client_id" value="3" type="radio"> > <label for="current_client_id_3">TestClientA</label> > > Then your ''When I choose'' should work. > > > > > 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?-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I found out what the problem is - My Ignorance about Capybara. I thought capybara would use the following port mentioned in my env.rb (as selenium was using and tests were running fine). Capybara.app_host = "http://localhost:3000" I did n''t know Capybara starts the app in a new server instance on a different port. Also it uses a test database instead of the app database. Database was the problem in my case. It didn''t have enough data to show the page html and so naturally capybara was n''t able to find the selector. Sorry for misleading you guys earlier(This is my first week on ruby stack). Thanks again Sofie & Philip. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 18, 2010, at 5:11 PM, pingu wrote:> HTML: <li> > <input id="current_client_id_3" name="current_client_id" > value="3" type="radio"> > <label for="TestClientA"> TestClientA</label> > </li>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: <li> <input id="current_client_id_3" name="current_client_id" value="3" type="radio"> <label for="current_client_id_3"> TestClientA</label> </li> Walter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks Walter> <li> > <input id="current_client_id_3" > name="current_client_id" > value="3" type="radio"> > <label for="current_client_id_3"> TestClientA</label> > </li> > > Walter-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Possibly Parallel Threads
- Cucumber Selenium web step to verify value of input field
- Ambiguous match error for Cucumber
- response.should have_content("1 movie") does not seem to work for me
- Problems running features with Textmate Cucumber bundle
- Cucumber Scenario Outlines Output Insufficient