如何在水豚中单击此按钮(使用“ ID”或“ Xpath”选择器)

Art*_*lin 0 ruby testing automation cucumber capybara

请帮我解决这个问题

我在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>
Run Code Online (Sandbox Code Playgroud)

我尝试使用:click_button“主菜单按钮”和find_button(“主菜单按钮”).click

但它给出了错误:

 Unable to find button "Organization" 
  (Capybara::ElementNotFound)
Run Code Online (Sandbox Code Playgroud)

Tho*_*ole 5

它不是一个按钮(或输入type = button)元素,因此click_button和find_button无法使用。你只需要做

find('#main-menu-button').click
Run Code Online (Sandbox Code Playgroud)