1

I am trying to click on text at this url http://ecos.fws.gov/ecp0/profile/speciesProfile?sId=6994, but can't come up with the right syntax.

What I want to do is click on "View All", but unfortunately there are multiple "View all"s in the html. The html looks like this:

<li style="margin-bottom:1em;">
<p><strong>Population location:</strong> Wherever found west of Mobile and Tombigbee Rivers in AL, MS, and LA</p>
<p><strong>Listing status:</strong> 
                    <span class="listingThreat">Threatened</span>
</p>
<ul>
<ul>
<li><b>States/US Territories</b> in which this population is known to or is believed to occur: 
    <a href="/ecp0/profile/countiesByState?entityId=181&amp;state=Alabama" onclick="window.open('', 'popup', 'width=800,height=550,scrollbars=yes,resizable=yes')" target="popup">Alabama</a>
    , <a href="/ecp0/profile/countiesByState?entityId=181&amp;state=Louisiana" onclick="window.open('', 'popup', 'width=800,height=550,scrollbars=yes,resizable=yes')" target="popup">Louisiana</a>
    , <a href="/ecp0/profile/countiesByState?entityId=181&amp;state=Mississippi" onclick="window.open('', 'popup', 'width=800,height=550,scrollbars=yes,resizable=yes')" target="popup">Mississippi</a>
</li>
<li><b>US Counties</b> in which this population is known to or is believed to occur: 
    <a href="/ecp0/profile/countiesBySpecies?entityId=181" onclick="window.open('', 'popup', 'width=800,height=550,scrollbars=yes,resizable=yes')" target="popup">View All</a></li>
<li><b>USFWS Refuges</b> in which this population is known to occur: 
    Bogue Chitto National Wildlife Refuge, Egmont Key National Wildlife Refuge, Grand Bay National Wildlife Refuge, Hobe Sound National Wildlife Refuge, Mississippi Sandhill Crane National Wildlife Refuge<br/>
</li>
</ul>
</ul>
</li>

I basically need to select where li style is "margin-bottom:1em;" and contains both "Threatened" and "View All". Unfortunately, for the url provided, there are two "View Alls", and both are within a li of style = "margin-bottome:1em;".

I just can't think of a way to uniquely identify the first "View All". I am thinking some kind of conditional path, but not sure

1 Answer 1

3

Try this xpath out - "//span[@class='listingThreat']/ancestor::li//a[text()='View All']"

Sign up to request clarification or add additional context in comments.

1 Comment

That worked perfectly. I am going to have to look up the /ancestor::li. I haven't seen that used with xpath.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.