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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:18:05+00:00 2026-05-18T00:18:05+00:00

In Cucumber, I’m trying to create a step like this: Then I should see

  • 0

In Cucumber, I’m trying to create a step like this:

Then I should see "Example business name" in the "Business name" input

I’d like the “Business name” input to be defined as “the input whose label has text “Business name.”

Here’s what I’ve got on the step so far:

Then /^I should see "([^"]*)" in the "([^"]*)" input$/ do |content, labeltext|
  # Not sure what to put here
end

In jQuery, I’d look for the label with that text, look at its “for” attribute, and find the input with that id. But the only selectors I’ve seen so far in Cucumber are these:

within("input:nth-child(#{pos.to_i}")

and

page.should have_content('foo')

Can anybody suggest a solution using the Webrat / Capybara selector syntax?

  • 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-18T00:18:06+00:00Added an answer on May 18, 2026 at 12:18 am

    Figured it out

    You can find an input by its label text using find_field(labeltext).

    # Example:
    # 'I should see "Howdy" in the "Greeting" input' ("Greeting" is the label text)
    Then /^I should see "([^"]*)" in the "([^"]*)" input$/ do |content, labeltext|
        find_field("#{labeltext}").value.should == content
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to cucumber and I have the following scenario: Then I should see
I am trying to do some Cucumber testing like the following: Given I am
For a cucumber step, I know that a particular ul element should have 5
I've got a cucumber step that is trying to populate objects, including a new
I'm using cucumber with my rails 3 app. My step definition works like so:
Im using Cucumber + Capybara. This is how one of my step definitions looks
I'm new to rails and cucumber and I'm trying to test the following scenario
I'm using Cucumber and Capybara and I'd like a way to simulate the request
Cucumber has a few different hook methods like Before, After or AfterStep. I was
When i run cucumber it displays the possible steps that i should define, an

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.