'Finding a button in Capybara

I'm trying to find this specific button. I've tried using find button in capybara to do this but I'm unable to.

find(:button, 'Open Cow menu').click

HTML Tag

<button class="cd-icon-button cd-button cd-irx-cyan-theme" type="button" ng-transclude="" aria-label="Open Cow menu" ng-click="$mdMenu.open($event)" aria-haspopup="true" aria-expanded="false" aria-owns="menu_container_1">
        <i class="fa fa-ellipsis-h" aria-hidden="true"></i>
    </button>

I'm sure there is a easier way of doing this.



Solution 1:[1]

Open Cow menu is the value of the aria-label attribute.

So you can use either of the following Locator Strategies:

find('button[aria-label=Open Cow menu]').click

or

find('button[aria-label="Open Cow menu"]').click

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 undetected Selenium