Home > Net >  Finding a button in Capybara
Finding a button in Capybara

Time:04-07

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  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  aria-hidden="true"></i>
    </button>

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

CodePudding user response:

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
  • Related