capybara - How to find element within fieldset with no class or id -
i have 2 field-set on page. none of them have id or class. want fill specific field in second field-set.
currently doing not working:
within_fieldset('fieldset') fill_in 'app_answers_attributes_0_answer', with: 'my first answer' end click_on 'submit'
and giving error:
capybara::elementnotfound: unable find fieldset "fieldset"
any idea on how that?
within_fieldset
takes id or legend text of fieldset - http://www.rubydoc.info/gems/capybara/capybara/session#within_fieldset-instance_method - it's not surprising within_fieldset('fieldset')
isn't working you. how can want depends on how you're html structured. instance if you're fieldsets have legends
<fieldset> <legend>something</legened> ... </fieldset> <fieldset> <legend>other thing</legened> ... </fieldset>
you can
within_fieldset('other thing') ... end
if don't have legends, have wrapping elements
<div id="first_section"> ... <fieldset>...</fieldset> <div> <div id="second_section"> <fieldset>...</fieldset> </div>
then can scope using css correct fieldset
within('#second_section fieldset') ... end
if instead fieldsets siblings
<div> <fieldset>...</fieldset> <fieldset>...</fieldset> </div>
then can scope second fieldset css sibling selector
within("fieldset + fieldset") ... end
Comments
Post a Comment