下面是 HTML 页面
<div class="box">
<div class="box3 disbox"></div>
<div class="box3 top"><input type="hidden" value="38206" name="jdh0">
<div class="box3-1 bg1">1</div>
<div class="clear"></div>
</div>
<div class="box3 top"><input type="hidden" value="38215" name="jdh1">
<div class="box3-1 bg1">2</div>
<div class="clear"></div>
</div>
<div class="box3 top"><input type="hidden" value="38214" name="jdh2">
<div class="box3-1 bg1">3</div>
<div class="clear"></div>
</div>
<div class="box3 top"><input type="hidden" value="38216" name="jdh3">
<div class="box3-1 bg1">4</div>
<div class="clear"></div>
</div>
</div>
我想要的 div 计数总数<div class="box3 top">等于<div class="box">
我尝试使用下面的代码,但它会计算所有 div 的数量,而与类无关,请让我知道如何根据类名称计算 div 数量?
WebElement resultGrid = driver.findElement(By.xpath("/html/body/div[4]/div/div/div[1]/div[4]"))
List<WebElement>totalRow = resultGrid.findElements(By.tagName("div"))
慕标琳琳
相关分类