2017-03-07 54 views
2

我工作的一個項目使用jQuery獲得表列值數組,有它獲取動態創建的表。我想從表中獲取列值作爲Array使用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); 

請幫助我。 謝謝你

+0

'Array.prototype.push()'不適用於字符串。 – Jai

+0

我可以使用什麼? – Rehan

回答

1

你可以簡單地使用量角器的getText()方法在ElementArrayFinder上得到值作爲數組。嘗試下面的代碼。

element.all('.table tbody tr td:nth-child(5)').getText().then(function(textArray){ 
    console.log(textArray); 
}) 
+0

可以將textArray存儲在新數組中? – Rehan