Here are a few different ways:
expect(page).to have_selector("a[href='#'][data-content='This is a discrete bar chart.']") page.has_selector?("a[href='#'][data-content='This is a discrete bar chart.']") page.find("a[href='#'][data-content='This is a discrete bar chart.']") # returns the node found
If you don’t have access to the page, but have access to view,
expect(Capybara.string(rendered)).to have_selector("a[href='#'][data-content='This is a discrete bar chart.']")
source share