Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 645 Vote(s) - 3.46 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to select option in drop down using Capybara

#1
I'm trying to select an item from a drop down menu using Capybara (2.1.0).

I want to select by number (meaning select the second, third, etc option).

I've Googled like crazy trying all sorts of things but no luck.

I was able to select it by using the value:

find("option[value='4c430d62-f1ba-474f-8e8a-4452c55ea0a8']").click

But I don't want to use that method b/c the value is something that will change and that will make my test brittle.

The HTML for the drop down is:

<td class="value">
<select name="organizationSelect" id="organizationSelect" class="required">
<option value="NULL">Choose...</option>
<option value="4c430d62-f1ba-474f-8e8a-4452c55ea0a8"> Institution1</option>
<option value="e1a4efa7-352d-410a-957e-35c8a3b92944"> Institution / test</option>
</select>
</td>

I also tried this:

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

But it results in this error:

Ambiguous match, found 2 elements matching option "Institution" (Capybara::Ambiguous)

So how can I select the first, second, third, etc option from the drop down (using Capybara) ?
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through