Count the number of elements are matching with for the given xpath expression

前端 未结 4 1704
自闭症患者
自闭症患者 2021-02-14 20:35

How to count the number of elements are matching with for the given xpath expression

xpath: driver.findElement(By.xpath(\"//div[contains(@id,\'richedittext_insta         


        
4条回答
  •  离开以前
    2021-02-14 21:17

    Try this code:

    //Assume driver is intialized properly.
    int iCount = 0;
    iCount = driver.findElements(By.xpath("Xpath Value")).size());
    

    The iCount has the number of elements having the same xpath value.

提交回复
热议问题