Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9001605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:27:31+00:00 2026-06-16T00:27:31+00:00

Trying to make this test to fail without success. I’ve got this HTML: <div

  • 0

Trying to make this test to fail without success.

I’ve got this HTML:

<div id="navigation">
 <ul>
  <li>
   <a href="/url">TV</a>

And then I was trying to identify the text of the A element and make it fail for now.

I’ve used all the following expressions with Xpath but all of them keep passing even though I’m using a different text for the comparison :S

page.should have_xpath("//div[@id='navigation']//a", :content => 'Radio')
page.should have_xpath("//div[@id='navigation']//a", :text => 'Radio')
page.should have_xpath("//div[@id='navigation']//a[contains(string(),'Radio')]")
page.should have_xpath("//div[@id='navigation']//a[contains(text(),'Radio')]")
page.should have_xpath("//div[@id='navigation']//a[contains(.,'Radio')]")

Any idea how I could identify the text of an specific HTML element with capybara?
and… is it possible to achieve the same with CSS?

Cheers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:27:32+00:00Added an answer on June 16, 2026 at 12:27 am

    It turns out that there was another element with the text ‘Radio’ in the ‘navigation’ DIV, so that was causing the test to fail.

    For future reference, identifying the 1st element explicitly behaved as expected and fails the test:

    page.first('div#navigation a').text.should == 'Radio')
    page.first('div#navigation a').text.should eq('Radio')
    page.first('div#navigation a').text.should match('Radio')
    page.first('div#navigation a').text.should be('Radio')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this test page: http://www.problemio.com/index_new.php and I am trying to make some jQuery
I need some help guys, trying to make this test to pass but with
I'm trying to use define in GNU make. Running make on this test Makefile
I have this test page: http://www.problemio.com/problems/problem.php?problem_id=305 I am trying to make the form towards
I'm trying to make a single-file HTML test case for something + part of
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I am trying to make this sample program work (defn foo ([x] (foo x
I'm trying to make this: 174,myfilename.jpg Into this on the php post process page:
I'm trying to make this regex ^(?!\-\-\sRoaming) to match with -- Roaming but it
I'm trying to make this request to the RunKeeper API : GET /user HTTP/1.1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.