DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

n350071๐Ÿ‡ฏ๐Ÿ‡ต
n350071๐Ÿ‡ฏ๐Ÿ‡ต

Posted on • Updated 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)

Top Heroku Alternatives (For Free)

>> Check out this classic DEV post <<