Unable to select a value from drop down in cucumber capybara

capybaracucumber

I am using cucumber with capybara to automate the web application. i have to select a value from a drop down , but many time i am getting an error like; "wrong argument type String (expected Array) (TypeError)"

I tried with:
1.

second_option_xpath = ".//*[@id='selecttype']/option[2]"  
second_option = find(:xpath, second_option_xpath).text
select(second_option, :from => 'selecttype')

2.

select "Selenium Core", :from => 'selecttype'

3.

page.find_and_select_option("selecttype", 2)

4.

select( "selecttype", {"Selenium Core" => 2})

PAGE SOURCE IS SOMETHING LIKE:

<select id="selecttype"> 
<option value="Selenium IDE">Selenium IDE</option> 
<option value="Selenium Code">Selenium Core</option> 
<option value="Selenium RC">Selenium RC</option> 
<option value="Selenium Grid">Selenium Grid</option> 
</select>"

Please suggest where i am doing wrong?

Thanks

Best Answer

Have you tried

page.select('Selenium Core', :from => 'selecttype')
Related Topic