DEV Community

n350071πŸ‡―πŸ‡΅
n350071πŸ‡―πŸ‡΅

Posted on β€’ Edited on

2 2

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay