简体   繁体   中英

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

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.

Considering you only one element with class = error

.error is the CSS selector.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM