Having some trouble locating the index of the column name Customers
within a table using jQuery/javascript. No matter what I try, it always returns -1
let tableDatacy = "Results_Table";
let columnName = "Customer";
let tableHeaders = [];
tableHeaders = Cypress.$(`[data-cy=${tableDatacy}] > thead:nth-child(0) > tr:contains(${columnName})`);
let columnPosition = tableHeaders.toString().indexOf(columnName);
<table data-cy="Results_Table">
<thead class="HeaderOriginal">
<tr class="tablesorter-headerRow">
<th class="hideExport hidePrint tablesorter-header" data-column="0" tabindex="0" unselectable="on" style="user-select: none;"><div class="tablesorter-header-inner"> </div></th>
<th class="ajaxOrder tablesorter-header" order="customer" data-column="3" tabindex="0" unselectable="on" style="user-select: none;">
<div class="tablesorter-header-inner">
<a href="javascript: void(0);" class="desc">Customers</a>
</div>
</th>
<th class="hideExport" data-column="0" tabindex="0" unselectable="on" style="user-select: none;"><div class="tablesorter-header-inner"> </div></th>
<th class="ajaxOrder tablesorter-header" order="customer" data-column="3" tabindex="0" unselectable="on" style="user-select: none;">
<div class="tablesorter-header-inner">
<a href="javascript: void(0);" class="desc">Machine</a>
</div>
</th>
</tr>
</thead>
</table>