selenium webdriver getText返回

我有一个selenium脚本,应该从包含所需值的单元格后的表格列中获取文本。

我有脚本工作,但由于某种原因,当我运行getText(),并检查返回的值我得到[对象对象]在我的node.js控制台…我很困惑我试图parsing它为一个string,我已经调用了该variables的getText()将是元素和其他几种方式,但无济于事…

这里是我的脚本部分:

if(tempID!=1){ //tr[contains(td[1], "ID#")]/td[#] scrapeArray[0] = tempID; console.log(scrapeArray[0]); } }).then(function(){ scrapeArray[1] = String(driver.findElement(webdriver.By.xpath('//tr[contains(td[1], "'+tempID+'")]/td[2]')).text()); console.log("1: "+scrapeArray[1]); }).then(function(){ scrapeArray[2] = String(driver.findElement(webdriver.By.xpath('//tr[contains(td[1], "'+tempID+'")]/td[3]')).text()); console.log("2: "+scrapeArray[2]); }).then(function(){ scrapeArray[3] = String(driver.findElement(webdriver.By.xpath('//tr[contains(td[1], "'+tempID+'")]/td[4]')).text()); console.log("3: "+scrapeArray[3]); }).then(function(){ scrapeArray[4] = String(driver.findElement(webdriver.By.xpath('//tr[contains(td[1], "'+tempID+'")]/td[5]')).text()); console.log("4: "+scrapeArray[4]); }).then(function(){ scrapeArray[5] = String(driver.findElement(webdriver.By.xpath('//tr[contains(td[1], "'+tempID+'")]/td[6]')).text()); console.log("5: "+scrapeArray[5]); }).then(function(){ scrapeArray[6] = String(driver.findElement(webdriver.By.xpath('//tr[contains(td[1], "'+tempID+'")]/td[7]')).text()); console.log("6: "+scrapeArray[6]); }).then(function(){ numberOf++; driverLoop(); }).then(null, function(err){ console.log("IDs Complete!"); }); 

我知道这是一个老问题,但我有同样的问题(除了使用webdriver.io),解决的办法是[对象对象]实际上是一个Promise对象(而不是我期待的string – 我在看API的错误版本)。 ...getText().then((text)=>{ console.log(text);}); 应该pipe用。