我在网页上有4个Upload按钮。每个上传按钮都具有上传文件的通用功能。如何使用Selenium Webdriver查找网页上多个按钮的数量
我无法使用Selenium webdriver获取这些按钮的数量。 按钮的ID是:
- buttonUpload_1
- buttonUpload_2
- buttonUpload_3
- buttonUpload_4。
这些按钮的常见实体类名buttonSecondary smallButton
我曾尝试下面的命令来获取数,但未能:
List<WebElement> buttoncount = driver.findElements(By.className(("buttonSecondary smallButton")));
List<WebElement> buttoncount = driver.findElements(By.xpath("//input[@class='buttonSecondary smallButton']"));
感谢您的建议。但是,我将计数作为零,而不是正确的计数。 你的建议确实有意义,但不幸的是它不工作.. 任何其他建议使用其名称的一部分来标识元素? –
@BAshwin考虑到你在问题中提供了什么,它应该起作用。提供元素的HTML表示或链接到我们可以看到它的网站。另外,页面上是否有任何iframe?谢谢。 – alecxe
Here you go,下面是html代码: