简体   繁体   中英

How to locate indistinct list items with xpath for Selenium IDE?

I'm trying to set up some automated test cases with WebDriver, using Selenium IDE with FireBug to get a good idea of what I'm doing. I've got it mostly figured out except for one major thing. This element

<div class="select2-drop select2-display-none select2-with-searchbox select2-drop-active select2-drop-above" style="left: 1200.5px; width: 438px; top: auto; bottom: 152px; display: block;" id="select2-drop">

opens a dropdown menu full of list items. EVERY item has the same id and class, set as a list item. Example:

<li class="select2-results-dept-0 select2-result select2-result-selectable">
<div class="select2-result-label">
<span class="select2-match"></span>
Copyright
</div>
</li>

The only difference between each list item is what's located inside the div tags, right after the span tags.

How do I differ each of these from the other using Selenium IDE? It won't record anything selected in the drop-down menu, or the drop-down itself. I've worked around clicking the drop-down with manually submitting the code. How would I find each element's Xpath, and translate that into a click command for WebDriver?

使用xpath来查找带有文本的元素。

//li[contains(text(),'dropdownValue')]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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