在这里,我尝试使用xpath作为.// div [@ class =“ pq-select-menu”] // span [contains(text(),“ filecaseone”)] / parent :: label来定位它/输入 和代码段如下
<div class="pq-select-popup ui-widget-content ui-corner-all" style="width: 300px;">
<label class="pq-select-all ui-widget-header ui-corner-all">
<span class="ui-icon ui-icon-close "></span>
<input type="checkbox">Select All</label>
<div class="pq-select-search-div ui-corner-all">
<span class="ui-icon ui-icon-search "></span>
<div class="pq-select-search-div1">
<input type="text" class="pq-select-search-input" autocomplete="off"></div></div>
<div class="pq-select-menu">
<label class="pq-select-option-label ui-state-enable" id="pq-option-528-0">
<input type="checkbox"><span class="pq-left-input">abc1203</span></label>
<label class="pq-select-option-label ui-state-enable" id="pq-option-528-1">
<input type="checkbox"><span class="pq-left-input">abc123</span></label>
<label class="pq-select-option-label ui-state-enable" id="pq-option-528-2">
<input type="checkbox"><span class="pq-left-input">CRdemoCase</span></label>
<label class="pq-select-option-label ui-state-enable" id="pq-option-528-3">
<input type="checkbox"><span class="pq-left-input">exportCase</span></label>
<label class="pq-select-option-label ui-state-enable" id="pq-option-528-4">
<input type="checkbox"><span class="pq-left-input">hdfhdfhdfdfgdfgdfgd</span></label>
<label class="pq-select-option-label ui-state-enable" id="pq-option-528-5">
<input type="checkbox"><span class="pq-left-input">Quinccasenewone1002</span></label>
<label class="pq-select-option-label ui-state-enable" id="pq-option-528-6">
<input type="checkbox"><span class="pq-left-input">Quinccasenewone1003</span></label>
<label class="pq-select-option-label ui-state-enable" id="pq-option-528-7">
<input type="checkbox"><span class="pq-left-input">Quinccasenewone1004</span>
</label><label class="pq-select-option-label ui-state-enable pq-state-hover" id="pq-option-528-8">
<input type="checkbox"><span class="pq-left-input">Quinccasenewone1006</span></label>
<label class="pq-select-option-label ui-state-enable" id="pq-option-528-9">
<input type="checkbox"><span class="pq-left-input">Quinccasenewone1007</span></label>
<label class="pq-select-option-label ui-state-enable" id="pq-option-528-10">
<input type="checkbox"><span class="pq-left-input">Quinccasenewone1100</span></label>
<label class="pq-select-option-label ui-state-enable" id="pq-option-528-11">
<input type="checkbox"><span class="pq-left-input">Quinccasenewone1101</span></label>
<label class="pq-select-option-label ui-state-enable" id="pq-option-528-12"><input type="checkbox"><span class="pq-left-input">testCase</span></label></div></div>
在打字稿量角器中,我正在找到多个具有相同标签的元素,如何找到第一个元素
我尝试了循环以及.first
let inputEle = element.all(by.xpath('.//div[@class="pq-select-menu"]//span[contains(text(), "filecaseone")]/parent::label/input'));
for (i=0; i < inputEle.count; i++){
valueInList= await inputEle.[0].isSelected());
}
element.all(locator).first()
let val=await inputEle.first().isSelected();
答案 0 :(得分:0)
尝试以下
const list = element.all(by.css('span.pq-left-input'));
await ele.get(0);
希望它对您有帮助