在表中使用xpath进行遍历时,Protractor将返回对象而不是值

Protractor is returning the object instead of the value when traversing using xpath in table

本文关键字:返回 Protractor 对象 xpath 遍历      更新时间:2023-09-26

我是量角器的新手。我使用它来使用xpath从表中获取值。当我运行下面的代码时,它将返回对象,而不是td值

量角器代码:var result=元素(通过.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);
 });