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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:19:15+00:00 2026-06-17T20:19:15+00:00

I have a table in my app. Using Capybara and Cucumber, how do I

  • 0

I have a table in my app.

enter image description here

Using Capybara and Cucumber, how do I assert that values 4.5 and 1.1 happen only in the Mike’s row?
Is such assertion possible in Capybara?

Thanks!

  • 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-17T20:19:16+00:00Added an answer on June 17, 2026 at 8:19 pm

    Yes, it’s possible and easy:

    def td_text(n)
      find(:xpath, "./td[#{n}]").text
    end
    
    h = {2 => 4.5, 3 => 1.1}
    
    all('table tr').each do |row|
      within row do
        if td_text(1) == 'Mike'
          h.each { |i, value| td_text(i).should == value.to_s }
        else
          h.each { |i, value| td_text(i).should_not == value.to_s }
        end
      end
    end
    

    Here’s full script that you can use for testing

    Update: I thought about it more. The code above will be very slow as every invocation of find and text in td_text will make new query to browser.

    The only way to mitigate it that I see is to use JS and Nokogiri:

    source = page.evaluate_script("document.getElementsByTagName('table')[0].innerHTML")
    
    doc = Nokogiri::HTML(source)
    
    def td_text(row, n)
      row.xpath("./td[#{n}]").text
    end
    
    h = {2 => 4.5, 3 => 1.1}
    
    doc.css('tr').each do |row|
      if td_text(row, 1) == 'Mike'
        h.each { |i, value| td_text(row, i).should == value.to_s }
      else
        h.each { |i, value| td_text(row, i).should_not == value.to_s }
      end
    end
    

    The first variant of code runs about 200 milliseconds at my machine though the second one – 8 milliseconds. Good optimization!

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

Sidebar

Related Questions

I'm using Google App Engine and Django templates. I have a table that I
I have an ASP.Net-MVC app using LinqToSql. I have a subcontracts table, a service_lines
I am building an app using storyboard. I have added a table view to
I have a simple cakephp app with table articles that has a cat_id column
I have an app that presents Table View of different files. I have it
I'm trying to dynamically update a table of values using SocketStream. I have a
I have a Rails app using a Postgres database with a table called geolite_blocks.
Using the Entity Framework that I generated. I have a Roles table created during
I'm creating an iPhone app using storyboard. I have a table view and 4
I have a table in my app named admin and I'm using the code

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.