I'm using Selenium to try and get some elements on a web page but I'm having trouble getting the ones I want. I'm getting some, but they're not the ones I want.

So what I have on my page are five divs that look like this:

```
<div class="membershipDetails">

```

Inside each one is something like this:

```
<div class="membershipDetail">
<h3>
    <a href="/EditMembership/111112">VIP Membership</a>
</h3>    
</div>

```

They DO all have this same link, but they don't have the same text ('VIP Membership' would be replaced by something else)

So the first thing was to get all the divs above in a list. This is the line I use:

```
listElementsMembership = driver.find_elements_by_css_selector(div[class^='membershipDetail'])

```

This gives me five elements, just as I would expect. I checked the 'class' attribute name and they are what I would expect. At this point I should say that they aren't all EXACTLY the same name 'membershipDetail'. Some have variations. But I can see that I have all five.

The next thing is to go through these elements and try and get that element which contains the href ('VIP Membership').

So I did that like this:

```
for elem in listElementsMembership:
elemDetailsLink = elem.find_element_by_xpath('//a[contains(@href,"EditMembership")]')

```

Now this does return something, but it always got me the element from the FIRST of the five elements. It's as if the 'elem.find\_element\_by\_xpath' line is going up a level first before finding these hrefs. I kind of confirmed this by switching this to a 'find\_elements\_by\_xpath' (plural) and getting, you guessed it, five elements.

So is this line:

```
elemDetailsLink = elem.find_element_by_xpath('//a[contains(@href,"EditMembership")]')

```

going up a level before getting its results? If it is, now can I make it not do that and just restrict itself to the children?