Skip to content

Latest commit

 

History

History
22 lines (18 loc) · 784 Bytes

click-on-text-with-capybara.md

File metadata and controls

22 lines (18 loc) · 784 Bytes

Click On Text With Capybara

Traditionally, web apps have clickable text in the form of links and buttons. Capybara's click_on method is made for just this.

click_on("Home") # for <a ... >Home</a>
click_on("Submit") # for <button ...>Submit</button>

A lot of more modern, JS-heavy apps stick click handlers on all kinds of elements. If you want to test what happens when you click some text that is not a link or button, click_on won't work. Instead, you'll need to find the element and click on it.

find("span", text: "Click Me").click