-1

I need to verify if the table headers exist. Any idea on how i can make my test select the headers. I do not have ID or css selector available. Xpath does not seem to work as well.

<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>
Automation89
  • 31
  • 1
  • 8
  • What was the xpath command you used? I see no reason why `element(by.xpath('tbody th:nth-child(x)'))` would not work – Ben Mohorc Feb 19 '18 at 21:22

1 Answers1

0

Check this xpath: //table/tbody/tr[th[.='Zip Code']] in browser DevTool to see it can find your desired table head, If so try element(by.xpath("//table/tbody/tr[th[.='Zip Code']]"))

yong
  • 13,357
  • 1
  • 16
  • 27