【发布时间】:2022-11-16 02:12:06
【问题描述】:
拜托,我对自动化很陌生,一直在电子商务网站上练习。 我正在尝试根据价格以相反的顺序对项目进行排序,然后单击价格排名第 5 的项目。我卡住了
这是我的代码:
List<WebElement> price = driver.findElements(By.xpath("//span[@class='a-price-whole']"));
// extract the prices from the price elements and store in a List
List<Float> prices = new ArrayList<Float>();
for (WebElement e : price)
{
prices.add(Float.parseFloat(e.getText()));
}
// sort the list
Collections.sort(prices);
Collections.reverse(prices);
请协助
【问题讨论】:
标签: java selenium-webdriver automated-tests