Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要找到从字母 alabama 开始的li所有div元素。class它可以是class="alabama12"或class="alabamaNY"或任何其他
li
div
class
class="alabama12"
class="alabamaNY"
以下代码仅定位那些li完全属于的元素alabama
alabama
allElements = driver.findElements(By.xpath("//div[@class='alabama']/ul/li"));
如何嵌入regex到By.xpath...?
regex
By.xpath...
没有必要使用正则表达式,XPath 对于这个查询来说已经足够强大了:
//div[starts-with(@class,'alabama')]/ul/li