如何验证表头是否存在 - Protractor,CucumberJS

时间:2018-02-19 21:14:43

标签: angular protractor cucumberjs

我需要验证表头是否存在。关于如何让我的测试选择标题的任何想法。我没有ID或css选择器。 Xpath似乎也没有用。

<div _ngcontent-c2="" class="ng-star-inserted">  
<table _ngcontent-c2="" cellspacing="0" width="70%">
<tbody _ngcontent-c2=""><tr _ngcontent-c2="">
  <th _ngcontent-c2="">Date</th>
  <th _ngcontent-c2="">Month</th>
  <th _ngcontent-c2="">First Name</th>
  <th _ngcontent-c2="">Middle Name</th>
  <th _ngcontent-c2="">Last Name</th>
  <th _ngcontent-c2="">Zip Code</th>
  <th _ngcontent-c2="">Work Zip Code</th>
  <th _ngcontent-c2="">Address</th>      
  <th _ngcontent-c2="">Work Address</th>
  <th _ngcontent-c2="">Team</th>
  <th _ngcontent-c2="">Team Code</th>
  <th _ngcontent-c2="">Team Size</th>
  <th _ngcontent-c2="">Active</th>      
  <th _ngcontent-c2="">Closed</th>

</tr>

1 个答案:

答案 0 :(得分:0)

在浏览器DevTool中检查此xpath://table/tbody/tr[th[.='Zip Code']]以查看它可以找到所需的表头,如果是,请尝试element(by.xpath("//table/tbody/tr[th[.='Zip Code']]"))