计算与给定 xpath 表达式匹配的元素数 [英] Count the number of elements are matching with for the given xpath expression
本文介绍了计算与给定 xpath 表达式匹配的元素数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何计算与给定 xpath 表达式匹配的元素数量
How to count the number of elements are matching with for the given xpath expression
xpath: driver.findElement(By.xpath("//div[contains(@id,'richedittext_instance')]"))
我需要的只是计数.
推荐答案
试试这个代码:
//Assume driver is intialized properly.
int iCount = 0;
iCount = driver.findElements(By.xpath("Xpath Value")).size());
iCount
具有相同 xpath
值的元素数量.
The iCount
has the number of elements having the same xpath
value.
这篇关于计算与给定 xpath 表达式匹配的元素数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文