BegJavaPy
BegJavaPy

Reputation: 95

How can i find the cssselector for the following error message

I am testing registration flow using selenium web driver. I have a field to enter email ID which shouldnt be the same as the user's emailId(user who is already registered). The code is mentioned below. I need to get the cssselector.

<em for="coworkeremail" class="error">Your co-worker's email must be different than yours</em>

Thanks Java beginner

Upvotes: 0

Views: 476

Answers (2)

ddavison
ddavison

Reputation: 29042

It's a little sketchy to match on that class, especially if there are more. error is a very generic class, so i'd say match on the for attribute.

em.error[for='coworkeremail']

Edit

As you say in the comments, your element is in a frame. Find the ID or Name of that frame, then execute,

driver.switchTo().frame("idOrName"); // assuming you are using Selenium 2 and Java

THEN find the element.

Upvotes: 1

Amey
Amey

Reputation: 8548

Considering you only one element with class = error

.error is the CSS selector.

Upvotes: 0

Related Questions