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)