Artur Abdullin
Artur Abdullin

Reputation: 61

How do i click this button in capybara (using 'ID' or 'Xpath' selector)

Please help me solve this problem

I have a button like in Capybara:

<li id="main-menu-button" data-radium="true" style="flex: 0 0 auto; padding:   0px; box-sizing: border-box; color: rgb(158, 144, 212); display: flex; margin: 5px; border-radius: 5px; width: 50px; height: 50px; flex-flow: row nowrap; justify-content: center; position: relative; transition: background-color 100ms ease-out;">
  <img src="/assets/images/branding/reachify-r-logo-white.png" alt="Logo" data-radium="true" style="width: 50px; height: 50px; padding: 10px; box-sizing: border-box; border-radius: 4px; background-color: rgba(0, 0, 0, 0.2);">
</li>

I tried with: click_button "main-menu-button" and find_button("main-menu-button").click

but it gives error:

 Unable to find button "Organization" 
  (Capybara::ElementNotFound)

Upvotes: 6

Views: 10327

Answers (1)

Thomas Walpole
Thomas Walpole

Reputation: 49870

It's not a button (or input type=button) element so click_button and find_button aren't going to work. You just need to do

find('#main-menu-button').click

Upvotes: 13

Related Questions