我试图点击此网址http://ecos.fws.gov/ecp0/profile/speciesProfile?sId=6994上的文字,但无法提供正确的语法。
我想要做的是点击"查看全部",但不幸的是,html中有多个"查看全部" s。 html看起来像这样:
<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&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&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&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>
我基本上需要选择li样式的位置&#34; margin-bottom:1em;&#34;并包含&#34;威胁&#34;和&#34;查看全部&#34;。不幸的是,对于提供的网址,有两个&#34;查看全部&#34;,两者都在style =&#34; margin-bottome:1em;&#34;的范围内。
我无法想出一种唯一识别第一个&#34;查看全部&#34;的方法。我在考虑某种条件路径,但不确定
答案 0 :(得分:3)
尝试使用此xpath - "//span[@class='listingThreat']/ancestor::li//a[text()='View All']"