英文:
How to get all the values against a particular tag in webpage
问题
有没有办法获取所有显示在“BRAND”下的值。
我想将所有显示为品牌的值存储在集合中,以便我可以将这些值与另一个集合进行比较,并找出在这些值之间哪些值会匹配。
以下是截图。请给予一些输入。
英文:
Is there any way to get all the values displaying against "BRAND" .
I want to store all the value that will display for the BRAND and sore those value in the collection so that I can compare with one more collection and find which value will get match in between those.
below is the screenshot . Please give some input .
答案1
得分: 1
可能是最简单的方法之一:
List<String> brands = new ArrayList<String>();
List<WebElement> fields = driver.findElements(By.className("asset-page__field-value"));
for (WebElement field: fields) {
brands.add(field.getText());
}
英文:
Probably the simplest way:
List<String> brands = new ArrayList<String>();
List<WebElement> fields = driver.findElements(By.className("asset-page__field-value"));
for (WebElement field: fields) {
brands.add(field.getText());
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论