I have a drop down menu. I want capybara to go through it and find the specific element and click on it. I'm currently trying to do a within clause and having it iterate through the list and find this element: "Cow_poop"
<li role="option" unselectable="on" title="Cow_poop" aria-selected="true" style="user-select: none;">Cow_pop</li>
This is the code that I'm trying to do.
find('div.ant-select-dropdown-menu-item-selected', text: 'Cow_poop').click
However it's giving me this error:
Capybara::ElementNotFound:
Unable to find css "div.ant-select-dropdown-menu-item-selected"
CodePudding user response:
It's not a <div>
but a <li>
element.
Your effective line of code will be:
find('li.ant-select-dropdown-menu-item-selected', title: 'Cow_poop').click
Alternative:
find('li.ant-select-dropdown-menu-item-selected[title=Cow_poop]').click