我正在尝试检索文字' GHYTH68JH'来自td对象。
我这样做的方式是:
Then(/^I should be able to download the PDF file '(.*)'$/, function (reportType, done) {
let obj = element(by.xpath("//td[2][text()='"+reportType+"']/../td[3]")).getText()
.then(function (text){
console.log(text);
done;
});
});
得到结果=未定义
我尝试过.getAttribute(' value')和.getAttribute(' innerHTML')并获得相同的结果。
这段代码的HTML是:
<tbody>
<tr class="ng-scope" ng-repeat="val in vm.Cases">
<td class="ng-binding" data-th="Date">26/05/2017</td>
<td class="ng-binding" data-th="Type">Report</td>
<td class="ng-binding" data-th="Order #">GHYTH68JH</td>
<td class="ng-binding" data-th="Ref"> </td>
<td class="ng-scope" ng-if="val.RStatus=='Available'">
<div class="download_button">
<span ng-click="vm.download(val.InciId,val.ONum)">Download</span>
</div>
</td>
</tr>
</tbody>
包装:
"protractor": "5.1.2",
"cucumber": "2.3.1",
"protractor-cucumber-framework": "3.1.2",
"chai": "3.5.0",
"chai-as-promised": "6.0.0",
"cucumber-html-reporter": "2.0.0",
"grunt-protractor-runner": "5.0.0",
"grunt-cli": "^1.2.0",
请不要将此问题标记为重复,因为我已尝试搜索解决方案并找到一些,因此在我的代码段中使用它们,但是,我无法从对象中获取文本。
随意将此问题与现有类似问题相关联。