我想查找 group1 中单选按钮的总数,我尝试使用以下代码,但系统抛出错误并建议我使用 getSize() 而不是 Size()。
System.out.println(dr.findElement(By.xpath("//input[@name= 'group2']")).size());
最佳答案
您可以使用 findElements()
方法并调用 size()
方法提取 size,如下所示:
System.out.println(driver.findElements(By.xpath("//input[@name='group2']")).size());
关于list - 如何查找 WebElements 列表的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49218978/