css selector for multiple ul elements

70 views
Skip to first unread message

burnt

unread,
Jan 15, 2009, 1:35:49 PM1/15/09
to selenium-users...@googlegroups.com
I have 2 ul elements that show up when when something bad happens in my web application.  I can use css selectors to find the first one, but I'm not sure how to find the second one.

Here is the x-path element for both of these:
/html/body/div[@id='main']/div[@id='content-box']/form[@id='users']/dl/dd[3]/ul/li
/html/body/div[@id='main']/div[@id='content-box']/form[@id='users']/dl/dd[4]/ul/li

I can find the first element with the following css
css=ul[class='errors']

but this of course only finds the first element.

The html looks similar to this.
<dd>
&nbsp;&nbsp;&nbsp;&nbsp; <ul class="errors">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <li>error text</li>
&nbsp;&nbsp;&nbsp;&nbsp; </ul>
</dd>
<dd>
&nbsp;&nbsp;&nbsp;&nbsp; <ul class="errors">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <li>some other error text</li>
&nbsp;&nbsp;&nbsp;&nbsp; <ul>
</dd>

burnt

unread,
Jan 16, 2009, 1:17:48 PM1/16/09
to selenium-users...@googlegroups.com
Thanks for the reply gim_h

I originally thought the same, but I kept getting
[error] locator not found: ...

I did find that css=dd:nth-child(8)>ul.errors will select the first error and
css=dd:nth-child(10)>ul.errors will select the second child.

Not sure why?&nbsp; Thanks for the reply.

Reply all
Reply to author
Forward
0 new messages