我正在一个项目上,有一个可以动态创建的表。我想使用jQuery从表中获取列值作为数组。
这是我到目前为止所做的,但是我遇到了这个错误。
Failed: unknown error: arguments[0].push is not a function
代码:
var myArray = [];
browser.executeScript("$(document).ready(function() { $('.table tbody tr td:nth-child(5)').each(function(i){ arguments[0].push($(this).text());});});",myArray);
console.log(myArray);
请帮我。
感谢你
最佳答案
您可以简单地在getText()
上使用量角器的ElementArrayFinder
方法以数组形式获取值。试试下面的代码。
element.all('.table tbody tr td:nth-child(5)').getText().then(function(textArray){
console.log(textArray);
})
关于javascript - 如何在 Protractor 中使用jQuery获取表列值作为数组,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42640845/