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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:03:53+00:00 2026-05-13T18:03:53+00:00

is it possible to follow a link by it’s class name instead of the

  • 0

is it possible to follow a link by it’s class name instead of the id, text or title? Given I have (haha, cucumber insider he?) the following html code:

<div id="some_information_container">
  <a href="edit" class="edit_button">Translation here</a>
</div>
  • I do not want to match by text because I’d have to care about the translation values in my tests
  • I want to have my buttons look all the same style, so I will use the CSS class.
  • I don’t want to assign a id to every single link, because some of them are perfectly identified through the container and the link class

Is there anything I missed in Cucumber/Webrat? Or do you have some advices to solve this in a better way?

Thanks for your help and best regards,

Joe

edit: I found an interesting discussion going on about this topic right here – seems to remain an open issue for now. Do you have any other solutions for this?

  • 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-13T18:03:54+00:00Added an answer on May 13, 2026 at 6:03 pm

    Here’s how I did it with cucumber, hope it helps. The # in the step definition helps the CSS understand whats going on.

    This only works with ID’s not class names

    Step Definition

    Then /^(?:|I )should see ([^\"]*) within a div with id "([^\"]*)"$/ do |text, selector|
      # checks for text within a specified div id
      within "##{selector}" do |content|  
        if defined?(Spec::Rails::Matchers)
          content.should contain(text)
        else
          hc = Webrat::Matchers::HasContent.new(text)
          assert hc.matches?(content), hc.failure_message
        end  
      end     
    end
    

    Feature

    Scenario Outline: Create Project
      When I fill in name with <title>
          And I select <data_type> from data_type
          And I press "Create"
      Then I should see <title> within a div with id "specifications"
    
    Scenarios: Search Terms and Results
       | data_type  | title        |
       | Books      | A Book Title |
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just a follow up question to this one here => link Is it possible
I have a follow up question to this question . Is it possible to
Possible Duplicate: Can I call jquery click() to follow an <a> link if I
Is it possible to map a table column to a class field instead to
I have no Idea about JTA,to understand the overall scenarios please follow this link
Where multiple people can work on same css. is it possible to follow semantic
I have a PHP while loop as follow: <?php while (have_posts()) : the_post(); ?>
I have the follow folder strucutre as default when creating a MVC project in
I currently have 2 pages: Follow.php :a PHP page which is all setup with
If we write something as follow: <a href=MyServlet>Link</a> It will call GET method of

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.