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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:15:40+00:00 2026-06-15T18:15:40+00:00

Two questions from a beginner. Q1- Is it possible to assert the existence of

  • 0

Two questions from a beginner.

Q1- Is it possible to assert the existence of an HTML node by ID and class?
For example, to see if the following element exists:

<div class="drawer" id="first"....>

I’ve seen you can use something like:

 page.should have_css('div.drawer')
 page.should have_css('div#first')

but can we somehow query for the existence of both parameters, I’ve tried the following and didn’t work:

page.should have_selector("div", :class => "drawer", :id => "first")

Q2- Is it possible to add 2 selectors to the ‘within’ capybara method, ie, I’ve seen you can limit the scope by doing:

within("//div[@id='first']") do

but can we filter that DIV by adding id=’first’ and class=’drawer’ somehow?

Many 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-15T18:15:41+00:00Added an answer on June 15, 2026 at 6:15 pm

    You can combine the selectors.

    For your first question, the following checks for a div with id “first” and class “drawer”:

    page.should have_css('div#first.drawer')
    

    For your second question, the within block can use the same css-selector as above:

    within('div#first.drawer') do
    

    Or if you really prefer xpath, you can do:

    within("//div[@id='first' and @class='drawer']") do
    

    A good reference for css-selectors: http://www.w3.org/TR/CSS2/selector.html

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

Sidebar

Related Questions

Two questions from a dns newb: Is it possible for a subdomain to use
I have two questions: From personal experience, what free blog engine is the best
Two questions: How can I import a file from a web address, without a
I have two questions. I want to send SMSes from a web-site in PHP
Two questions from a coding ub3r n00b... Firstly, I'm using the Options Framework Theme
I have the SQL text SELECT * FROM TABLE1 WITH (NOLOCK). Two questions: How
Really two questions: If I have a dictionary (that originally came from parsing a
Please note I am a beginner to this. I have two questions: 1) How
R beginner with a two part question - I like the one class per
Beginner's question: I'm trying to manipulate tuples from two different attributes in a relation

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.