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 6898355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:17:08+00:00 2026-05-27T07:17:08+00:00

Problem: Given a table, a specific piece of content should appear in the same

  • 0

Problem:
Given a table, a specific piece of content should appear in the same column as a specific header.

Clarification:
I can not test the column position numerically, or at least I can’t hardcode it that way, since the number of columns can change based on various other conditions and I don’t want to make my test that fragile.

Example:

Name || Phone Number || Address
==============================================================
 ... || ...          || ...
 Joe || 555-787-7878 || 42 Nowhere Lane, Mulberry, California
 ... || ...          ||

With the code looking like so:

<table>
  <tr>
    <th>Name</th>
    <th>Phone Number</th>
    <th>Registered</th>
    <th>Address</th>
  </tr>
  <tr>
    ...
  </tr>

  <tr>
    <td>Joe</td>
    <td>555-377-7347</td>
    <td>Yes</td>
    <td>42 Nowhere Lane1, Mulberry1, California</td>
  </tr>
  <tr>
    <td>Jerry</td>
    <td>555-787-7878</td>
    <td>Yes</td>
    <td>50 Nowhere Lane, Mulberry, California</td>
  </tr>

  <tr>
    <td>Tom</td>
    <td>555-678-0987</td>
    <td>No</td>
    <td>43 Nowhere Lane2, Mulberry2, California</td>
  </tr>
  <tr>
    ...
  </tr>
</table>

Scenario:
I want to insure the correct address (42 Nowhere…) appears in the column with the header “Address”.

How can I do this?

The solution might be as simple as a decent xpath query, to be honest, perhaps I don’t even need anything particularly “Capybara” related!

I came across similar one, but here I need to check whether ‘Jerry’ registered or not. Please help me how can i automate using ruby/capybara

Thanks in Advance

  • 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-05-27T07:17:08+00:00Added an answer on May 27, 2026 at 7:17 am

    I think @Snekse is very close. Here are some expressions that have been tested. The following returns the table cell corresponding to the th whose value is Address:

    /table/tr/td[(count(../../tr/th[.='Address']/preceding-sibling::*)+1)]
    

    This can be used to get the value of the cell:

    42 Nowhere Lane, Mulberry, California
    

    …which you could then use to perform the final test:

    /table/tr/td[(count(../../tr/th[.='Address']/preceding-sibling::*)+1)]
                                   [.='42 Nowhere Lane, Mulberry, California']
    

    This will return the cell itself, if the addresses match. It will return an empty node-set, which will evaluate to false in a boolean context, if no such node exists.

    You probably also need to specify the row you’re testing, which can be done with a slight modification to the start of the expression:

    /table/tr[$n]/<rest_of_expression>
    

    …where $n is the index of the row to select.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following html table and script shown below I am having a problem
I have a table of Likes (uid1 likes uid2) and given a specific userID
Problem Given the following two tables, I'd like to select all Ids for Posts
Problem: Given a list of strings, find the substring which, if subtracted from the
Here's the jist of the problem: Given a list of sets, such as: [
First the practical application that led me to the problem: Given a set of
Please help me out with an algorithm for the following problem - Given a
My given problem is follow: I have an object with x columns and every
The problem is : Given a number of programming libraries with similar or equal
I am given a problem where I have been given N nodes in a

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.