繁体   English   中英

如何在Selenium Webdriver中使用cssSelector识别多个参数

[英]How to identify multiple parameters using cssSelector in Selenium webdriver

谁能说出如何识别selenium webdriver的以下元素。 以下是它的html版本:

<select ng-model="tripDetails.destinationId" ng-change="$parent.$parent.$parent.updateTripSourceCity($index)" required="" class="ng-touched ng-dirty ng-valid-parse ng-valid ng-valid-required">

尝试使用以下CSS选择器通过类名标识它

select.ng-touched.ng-dirty.ng-valid-parse.ng-valid.ng-valid-required

我猜想这个类不是唯一的,所以最好通过ng-model选择。 尝试将其作为CSS选择器:

'select[ng-model="tripDetails.destinationId"]'

在您的情况下,最好使用xpath搜索该特定元素。 首先使用上面提到的元素的层次结构中上方的xpath搜索任何父元素,然后从该父元素中搜索您的元素。 试试这个

//parent-xpath/child-xpath(mentioned element)
//div[@id='element-id']/select[@ng-model='tripDetails.destinationId']

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM