Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sorting 如何使用Selenium验证记录的排序_Sorting_Testing_Selenium - Fatal编程技术网

Sorting 如何使用Selenium验证记录的排序

Sorting 如何使用Selenium验证记录的排序,sorting,testing,selenium,Sorting,Testing,Selenium,我有一份记录清单。如何使用Selenium验证排序顺序 List<WebElement> tableRowCollection = webTableElement .findElements(By.xpath("/table")); List tableRowCollection=webTableElement.findElements(By.xpath(“/table”); 我在上面的语句“类型列表不是泛型的;它不能用参数参数化”中得到一个错误。我不知道如何读取记录,因为fi

我有一份记录清单。如何使用Selenium验证排序顺序

List<WebElement> tableRowCollection = webTableElement .findElements(By.xpath("/table")); 
List tableRowCollection=webTableElement.findElements(By.xpath(“/table”);

我在上面的语句“类型列表不是泛型的;它不能用参数参数化”中得到一个错误。我不知道如何读取记录,因为findElements只返回WebElemt。

修复导入,您很可能没有导入
java.util.List

以下代码将整行文本添加到集合
元素

List<WebElement> tableRowCollection = webTableElement.findElements(By.xpath("/table"))
List<String> elements = new LinkedList<String>();
for (WebElement e : tableRowCollection) {
    elements.add(e.getText());
}
List tableRowCollection=webTableElement.findElements(By.xpath(“/table”))
列表元素=新的LinkedList();
for(WebElement e:tableRowCollection){
添加(e.getText());
}

这应该让您开始学习,但我确实建议您阅读一些与Java集合相关的文档。

您阅读页面上列表的内容,并将其与预期顺序的记录列表进行比较。。。到目前为止,您尝试了什么?您使用的是selenium IDE还是什么?因为没有实际的语言标记。我正在使用Selenium webdriver,我只是用代码更新了我的问题。请确保导入
import java.util.List
而不是awt one
WebElement
有一个方法
getText()