Solved

CSS Selector problem

Posted on 2014-03-27
2
235 Views
Last Modified: 2014-04-08
I have a problem to point out two objects having the same class.

If I use the CSS selector:

@FindBy(css = ".searchform .sprite.limitbox-trigger")

it points out both objects.

I need two different CSS selectors pointing out the objects separately.

Here is the code:

Object 1:

<input type="text" id="what" name="what" value="">
<a class="sprite limitbox-trigger  helper" href="#" data-text="Click to view extra options on how to limit your search"></a>

Object 2:

<input type="text" id="where" name="where" value="">
<a class="sprite limitbox-trigger  helper" href="#" data-text="Click to view extra options on how to limit your search"></a>


I understand I need to use the id="where" or name="where" but I don't get the combination with class to work...
0
Comment
Question by:Bear2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Expert Comment

by:soupBoy
ID: 39959042
Your id's should be unique, but if that won't work, you could always find the first one by using :first-of-type...however I don't believe that will work in IE8 (if you have to support it).

.searchform .sprite.limitbox-trigger:first-of-type

Open in new window


You mention using the input attributes...which could get ugly but might work for you
input[id="someID"] + .searchform .sprite.limitbox-trigger

Open in new window

I only used the ID as it would be unique...but you could easy 'chain' the other parts of the selector....  [id="someID"][name="someName"] etc.


Let me know if I am way off base with this...


- Chris
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39959116
Just use the adjacent sibling selector (+)

#what + .sprite.limitbox-trigger
#where + .sprite.limitbox-trigger

Open in new window

0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article you will learn how to create a free basic website on Bitbucket, a git service provider. Polymer creates dynamic HTML components, which allow more flexibility than static HTML. This tutorial uses Ubuntu Linux but can also be done on W…
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question