DEV Community

n350071🇯🇵
n350071🇯🇵

Posted on • Edited on

Test css(icon) in Capybara

🔗 Parent Note

🤔 Situation

Let's say you use Font Awesome. Then, you want to test that only one map-marker icon is visible on the page.

In other words, you want to find the css.

<i class="fas fa-map-marker"></i>

👍 Solution

There is Capybara::Node::Matchers#has_css?. You can also specify the visible count.

like this.

expect(has_css?('i.fa-map-marker', count: 1)).to eq true

Top comments (0)