Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在SeleniumWebDriver中使用cssSelector识别多个参数_Javascript_Java_Angularjs_Selenium_Selenium Webdriver - Fatal编程技术网

Javascript 如何在SeleniumWebDriver中使用cssSelector识别多个参数

Javascript 如何在SeleniumWebDriver中使用cssSelector识别多个参数,javascript,java,angularjs,selenium,selenium-webdriver,Javascript,Java,Angularjs,Selenium,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"> 尝试使

谁能告诉我如何在
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模型。尝试将此作为CSS选择器:

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

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

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

请更新您的编码部分@SaEChowdary这是它的html版本。之前您在问题中对此进行了评论。请阅读。请提供您尝试过的代码和执行结果,包括任何错误消息等。同时提供指向页面和/或相关HTML的链接。如果元素未找到,则抛出错误不起作用。
CSS
选择器无法以这种方式工作
//父CSS/子CSS
。。。它看起来像
XPath
<代码>CSS
选择器应该是
父CSS子CSS
。此外,OP表示未找到
select[ng model=“tripDetails.destinationId”]
。显然,
div[id='element-id']select[ng model='tripDetails.destinationId']
应该返回相同的结果