在 table 中使用 xpath 遍历时量角器返回对象而不是值
Protractor is returning the object instead of the value when traversing using xpath in table
我是量角器的新手。我正在使用它使用 xpath 从 table 获取值。当我 运行 下面的代码时,它返回对象而不是 td 值
量角器代码:
var result = element(by.xpath("//tr/td[@style='min-width:51px']"));
console.log("++++++++++++++++++"+ 结果);
输出:
+++++++++++++++++[对象对象]
HTML 页数:
<div class="ng-scope" ng-include="'product/main/views/ABC.html'" ng-if="context.pat">
<section class="module module-pat product-banner ng-scope" ng-controller="product.main.PBS">
<figure class="pat-photo pull-left">
<table class="table-overview pull-left">
<tbody>
<tr>
<td style="min-width:225px">
<td class="ng-binding" style="min-width:51px">F</td>
<td class="ng-binding" style="min-width:61px">56</td>
<td class="ng-binding" style="min-width:130px">1958-03-13</td>
<td class="ng-binding" style="min-width:115px">Welby</td>
<td class="ng-binding" style="min-width:178px">United</td>
<td class="ng-binding" style="min-width:80px">Yes</td
<td>
<span class="label label-important ng-binding"/>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<th class="pat-number ng-binding">123456789 </th>
<th class="ng-binding">Sex</th>
<th class="ng-binding">Age</th>
<th class="ng-binding">DOB</th>
<th class="ng-binding">PCP</th>
<th class="ng-binding">Country</th>
<th class="ng-binding">Insurance</th>
</tr>
</tfoot>
</table>
element(by.xpath("//tr/td[@style='min-width:51px']")).getText().then(function(result)
console.log("+++++++++++++++++"+ result);
});
我是量角器的新手。我正在使用它使用 xpath 从 table 获取值。当我 运行 下面的代码时,它返回对象而不是 td 值
量角器代码: var result = element(by.xpath("//tr/td[@style='min-width:51px']")); console.log("++++++++++++++++++"+ 结果);
输出: +++++++++++++++++[对象对象]
HTML 页数:
<div class="ng-scope" ng-include="'product/main/views/ABC.html'" ng-if="context.pat">
<section class="module module-pat product-banner ng-scope" ng-controller="product.main.PBS">
<figure class="pat-photo pull-left">
<table class="table-overview pull-left">
<tbody>
<tr>
<td style="min-width:225px">
<td class="ng-binding" style="min-width:51px">F</td>
<td class="ng-binding" style="min-width:61px">56</td>
<td class="ng-binding" style="min-width:130px">1958-03-13</td>
<td class="ng-binding" style="min-width:115px">Welby</td>
<td class="ng-binding" style="min-width:178px">United</td>
<td class="ng-binding" style="min-width:80px">Yes</td
<td>
<span class="label label-important ng-binding"/>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<th class="pat-number ng-binding">123456789 </th>
<th class="ng-binding">Sex</th>
<th class="ng-binding">Age</th>
<th class="ng-binding">DOB</th>
<th class="ng-binding">PCP</th>
<th class="ng-binding">Country</th>
<th class="ng-binding">Insurance</th>
</tr>
</tfoot>
</table>
element(by.xpath("//tr/td[@style='min-width:51px']")).getText().then(function(result)
console.log("+++++++++++++++++"+ result);
});