遇到CSS选择器问题

时间:2018-06-19 16:34:17

标签: selenium css-selectors

我似乎无法为此正确选择css选择器:

<p ng-bind-html="hotelItem.details.allDetails.policyCancellationInstructions" class="ng-binding">
<div>To cancel this reservation <a href="https://www.getaroom.com/reservations?signature=57c685104ad3fe1525f17d0f54f2bde23ec82596&amp;utm_campaign=Affiliate&amp;utm_medium=cpa&amp;utm_source=studentuniverse.com">click here</a>. If you have questions regarding your booking contact Getaroom's customer care team: United States Customers: <a href="tel:+18002603895">800-260-3895</a>; United Kingdom Customers: <a href="tel:+08000124507">0800-012-4507</a></div> 
</p>

我尝试了一下都没用:

'span[ng-bind-html="hotelItem.details.allDetails.policyCancellationInstructions"] > div'

任何帮助表示赞赏!

2 个答案:

答案 0 :(得分:0)

您可以在CSS选择器下方使用

body > div:nth-child(2)

答案 1 :(得分:0)

根据您共享的HTML:

获取 div (这实际上没有任何意义)

body div:nth-child(2) 

对于p节点:

p[ng-bind-html*='policyCancellationInstructions']  

要单击,请单击此处链接

a[href*='https://www.getaroom.com'] 

在这种情况下,我强烈建议您使用 linkText

要单击此号码 800-260-3895

a[href*='18002603895']  

,并单击该号码 0800-012-4507

a[href*='8000124507']