Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Handling dropdown in Capybara

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.08k
    Comment on it

    Handling dropdown is very easy in Capybara. Here we do not have to create the object of Select class and the select option through Select class object. We directly have to pass the option value which is to be selected to the desired location.

     

    Let's suppose we have following HTML:

    <select id="node_estimatedduration_id" name="node[estimatedduration_id]">
    
    <option value="">Select Duration</option>
    
    <option value="1">1-2 weeks</option>
    
    <option value="2">3-4 weeks</option>
    
    <option value="3">1-3 months</option>
    
    <option value="4">4-6 months</option>
    
    <option value="5">7-9 months</option>
    
    <option value="6">More than 9 months</option>
    
    <option value="7">Not sure</option>
    
    </select>
    
    
    Given(/^I select 7-9 months options from Duration dropdown/$)
    
       select '7-9 months' :from=> 'node_estimatedduration_id'

     

    Syntax: select '<option>' :from=> '<location>'

    First we have to give the option that we have select and then the location from where we have to select that option.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: