如何從列表中選擇元素?從列表框中選擇元素
ClickElementByXPath("//li[contains(text(), 'Legnica')]");
ClickElementByXPath("//li[contains(., 'Legnica')]");
沒有什麼工作
<ul tabIndex="-1" class="k-list k-reset" id="ArrangementsWN_BusinessUnitId_listbox" role="listbox" aria-hidden="true" aria-live="off" style="height: 177px; overflow: auto;" data-role="staticlist" unselectable="on">
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="0">Jelenia Góra</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="1">Legnica</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="2">Opole</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="3">Wałbrzych</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="4">Wrocław</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="5">Bielsko Biała</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="6">Będzin</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="7">Częstochowa</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="8">Kraków</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="9">Tarnów</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="10">Obcy PGE</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="11">Obcy ENEA</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="12">Obcy ENERGA</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="13">Gliwice</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="14">Centrala</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="15">TD Serwis</li>
<li tabIndex="-1" class="k-item" role="option" unselectable="on" data-offset-index="16">Wykonawca obcy</li>
</ul>
您的'XPath'似乎是正確的。用確切的例外日誌更新您的問題,並檢查列表中是否存在位於'
您要的究竟是什麼?你想使用已被點擊過的''''或者顯示項目的索引嗎?也許這[問題]的答案(http://stackoverflow.com/questions/26204120/get-li-element-onclick-with-pure-javascript-without-applying-onclick-to-each-ele)可以幫助你。 –
我想單擊元素 – crisx