Reputation: 559
Let's say that I have some html like:
<div id="container1" class="wrap">
<div class="somestyle">first content
</div>
</div>
<div id="container2" class="wrap">
<div class="somestyle">second content
</div>
</div>
.
.
.
<div id="containern" class="wrap">
<div class="somestyle">nth content
</div>
</div>
Recording tests with Selenium IDE, ID and CSS locator builders in the top, if I click on "first content" I get something like:
css=div.somestyle
on the other hand, if I click on any other content starting from the second, I get (what I want):
css=#container2 > div.somestyle,
.
.
.
css=#containern > div.somestyle
The only exception is the first element.
Why is that? Is it a bug? How can I avoid, without having to rewrite the whole HTML structure?
Upvotes: 0
Views: 1759
Reputation: 2002
As class for all three container is same, so to identify it records like that.It is not but. for eg. If you have three check box with same name then it will record
click | name=vehicle
click | xpath=(//input[@name='vehicle'])[2]
click | xpath=(//input[@name='vehicle'])[3]
In you code, class is same for all container.
So to identify container IDE code will display like you mentioned. For first it will display directly, will consider as first entry.
css=div.somestyle
And for next entries will go like
css=#container2 > div.somestyle,
.
.
.
css=#containern > div.somestyle
Upvotes: 1