I have the code below for my HTML, but my problem is selecting the specific WebElement (th) for my automation to click.
<div id="datatable-buttons_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer"><div class="dt-buttons btn-group"><a class="btn btn-default buttons-selected btn-primary disabled" tabindex="0" aria-controls="datatable-buttons"><span><i class="fa fa-edit"></i> Update Asset Details</span></a><a class="btn btn-default buttons-selected btn-primary disabled" tabindex="0" aria-controls="datatable-buttons"><span><i class="fa fa-hand-o-up"></i> Assign Asset</span></a><a class="btn btn-default btn-primary" tabindex="0" aria-controls="datatable-buttons"><span><i class="fa fa-file-excel-o"></i> Export Spreadsheet</span></a></div><table id="datatable-buttons" width="100%" class="viewAssetTable table table-striped table-bordered dataTable no-footer" role="grid" aria-describedby="datatable-buttons_info">
<thead>
<tr role="row"><th width="10%" class="sorting_disabled" rowspan="1" colspan="1" aria-label="Asset No. "><a data-url="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=asset_number&direction=asc" href="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=asset_number&direction=asc" class="data-reload">Asset No. <i class="fa fa-sort"> </i></a></th><th width="9%" class="sorting_disabled" rowspan="1" colspan="1" aria-label="Asset Type "><a data-url="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=AssetType.asset_type_name&direction=asc" href="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=AssetType.asset_type_name&direction=asc" class="data-reload">Asset Type <i class="fa fa-sort"> </i></a></th><th width="9%" class="sorting_disabled" rowspan="1" colspan="1" aria-label="Model "><a data-url="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=model&direction=asc" href="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=model&direction=asc" class="data-reload">Model <i class="fa fa-sort"> </i></a></th><th width="9%" class="sorting_disabled" rowspan="1" colspan="1" aria-label="Serial No. "><a data-url="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=serial_num&direction=asc" href="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=serial_num&direction=asc" class="data-reload">Serial No. <i class="fa fa-sort"> </i></a></th><th width="9%" class="sorting_disabled" rowspan="1" colspan="1" aria-label="Bundle No. "><a data-url="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=bundle_asset_id&direction=asc" href="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=bundle_asset_id&direction=asc" class="data-reload">Bundle No. <i class="fa fa-sort"> </i></a></th><th width="9%" class="sorting_disabled" rowspan="1" colspan="1" aria-label="Status "><a data-url="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=AssetStatus.asset_status_name&direction=asc" href="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=AssetStatus.asset_status_name&direction=asc" class="data-reload">Status <i class="fa fa-sort"> </i></a></th><th width="9%" class="sorting_disabled" rowspan="1" colspan="1" aria-label="Status Effective Date "><a data-url="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=status_effectivity_date&direction=asc" href="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=status_effectivity_date&direction=asc" class="data-reload">Status Effective Date <i class="fa fa-sort"> </i></a></th><th width="9%" class="sorting_disabled" rowspan="1" colspan="1" aria-label="User "><a data-url="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=Employee.employee_name&direction=asc" href="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=Employee.employee_name&direction=asc" class="data-reload">User <i class="fa fa-sort"> </i></a></th><th width="9%" class="sorting_disabled" rowspan="1" colspan="1" aria-label="Location "><a data-url="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=Location.location_name&direction=asc" href="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=Location.location_name&direction=asc" class="data-reload">Location <i class="fa fa-sort"> </i></a></th><th width="9%" class="sorting_disabled" rowspan="1" colspan="1" aria-label="Location Remarks "><a data-url="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=location_remarks&direction=asc" href="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=location_remarks&direction=asc" class="data-reload">Location Remarks <i class="fa fa-sort"> </i></a></th><th width="9%" class="sorting_disabled" rowspan="1" colspan="1" aria-label="Last Inventory "><a data-url="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=last_audit_date&direction=asc" href="/basket_uat/view-asset/search-asset?poNum=&controlNum=&bundleNum=&warrantyEndDate=&acquisitionDate=&employeeName=&salesInvoice=&deliveryReceipt=&model=&serialNum=&marketCircle=&project=&page=3&sort=last_audit_date&direction=asc" class="data-reload">Last Inventory <i class="fa fa-sort"> </i></a></th><th class="hide sorting" tabindex="0" aria-controls="datatable-buttons" rowspan="1" colspan="1" aria-label=": activate to sort column ascending"></th><th class="hide sorting" tabindex="0" aria-controls="datatable-buttons" rowspan="1" colspan="1" aria-label=": activate to sort column ascending"></th></tr>
</thead>
<tbody>
<tr role="row" class="odd">
<th scope="row" class="asset_number td-clickable">AN20160909191412</th>
<td>Desktop</td>
<td>Dell 0604</td>
<td>SN60609072016</td>
<td class="bundle_asset_id td-clickable"></td>
<td class="asset_status ">Assigned Permanent</td>
<td class="status_effectivity td-clickable">2016-09-10</td>
<td class="asset_user td-clickable">Admin Manager</td>
<td class="asset_location td-clickable">PICUP4FCA</td>
<td>Best</td>
<td class="asset_inventory td-clickable">2016-09-12</td>
<td class="hide asset_id">21</td>
<td class="hide can_be_parent">1</td>
</tr><tr role="row" class="even">
<th scope="row" class="asset_number td-clickable">AN20160909191722</th>
<td>Desktop</td>
<td>Dell 0604</td>
<td>SN60609072016</td>
<td class="bundle_asset_id td-clickable"></td>
<td class="asset_status ">Assigned Permanent</td>
<td class="status_effectivity td-clickable">2016-09-10</td>
<td class="asset_user td-clickable">Admin Manager</td>
<td class="asset_location td-clickable">PICUP4FCA</td>
<td>Best</td>
<td class="asset_inventory td-clickable">2016-09-12</td>
<td class="hide asset_id">22</td>
<td class="hide can_be_parent">1</td>
</tr><tr role="row" class="odd">
<th scope="row" class="asset_number td-clickable">AN20160909192932</th>
<td>Desktop</td>
<td>Dell 0604</td>
<td>SN60609072016</td>
<td class="bundle_asset_id td-clickable"></td>
<td class="asset_status ">Assigned Permanent</td>
<td class="status_effectivity td-clickable">2016-09-10</td>
<td class="asset_user td-clickable">Admin Manager</td>
<td class="asset_location td-clickable">PICUP4FCA</td>
<td>Best</td>
<td class="asset_inventory td-clickable">2016-09-12</td>
<td class="hide asset_id">23</td>
<td class="hide can_be_parent">1</td>
</tr><tr role="row" class="even">
<th scope="row" class="asset_number td-clickable">AN20160913103059</th>
<td>Desktop</td>
<td>Dell 0604</td>
<td>SN60609072016</td>
<td class="bundle_asset_id td-clickable"></td>
<td class="asset_status ">Assigned Permanent</td>
<td class="status_effectivity td-clickable">2016-09-10</td>
<td class="asset_user td-clickable">Admin Manager</td>
<td class="asset_location td-clickable">PICUP4FCA</td>
<td>Best</td>
<td class="asset_inventory td-clickable">2016-09-12</td>
<td class="hide asset_id">24</td>
<td class="hide can_be_parent">1</td>
</tr><tr role="row" class="odd">
<th scope="row" class="asset_number td-clickable">AN20160913104139</th>
<td>Desktop</td>
<td>Dell 0604</td>
<td>SN60609072016</td>
<td class="bundle_asset_id td-clickable"></td>
<td class="asset_status ">Assigned Permanent</td>
<td class="status_effectivity td-clickable">2016-09-10</td>
<td class="asset_user td-clickable">Admin Manager</td>
<td class="asset_location td-clickable">PICUP4FCA</td>
<td>Best</td>
<td class="asset_inventory td-clickable">2016-09-12</td>
<td class="hide asset_id">25</td>
<td class="hide can_be_parent">1</td>
</tr><tr role="row" class="even">
<th scope="row" class="asset_number td-clickable">AN20160913110714</th>
<td>Desktop</td>
<td>Dell 0604</td>
<td>SN60609072016</td>
<td class="bundle_asset_id td-clickable"></td>
<td class="asset_status ">Assigned Permanent</td>
<td class="status_effectivity td-clickable">2016-09-10</td>
<td class="asset_user td-clickable">Admin Manager</td>
<td class="asset_location td-clickable">PICUP4FCA</td>
<td>Best</td>
<td class="asset_inventory td-clickable">2016-09-12</td>
<td class="hide asset_id">26</td>
<td class="hide can_be_parent">1</td>
</tr><tr role="row" class="odd">
<th scope="row" class="asset_number td-clickable">AN20160913110915</th>
<td>Desktop</td>
<td>Dell 0604</td>
<td>SN60609072016</td>
<td class="bundle_asset_id td-clickable"></td>
<td class="asset_status ">Assigned Permanent</td>
<td class="status_effectivity td-clickable">2016-09-10</td>
<td class="asset_user td-clickable">Admin Manager</td>
<td class="asset_location td-clickable">PICUP4FCA</td>
<td>Best</td>
<td class="asset_inventory td-clickable">2016-09-12</td>
<td class="hide asset_id">27</td>
<td class="hide can_be_parent">1</td>
</tr><tr role="row" class="even">
<th scope="row" class="asset_number td-clickable">AN20160913111125</th>
<td>Desktop</td>
<td>Dell 0604</td>
<td>SN60609072016</td>
<td class="bundle_asset_id td-clickable"></td>
<td class="asset_status ">Assigned Permanent</td>
<td class="status_effectivity td-clickable">2016-09-10</td>
<td class="asset_user td-clickable">Admin Manager</td>
<td class="asset_location td-clickable">PICUP4FCA</td>
<td>Best</td>
<td class="asset_inventory td-clickable">2016-09-12</td>
<td class="hide asset_id">28</td>
<td class="hide can_be_parent">1</td>
</tr><tr role="row" class="odd">
<th scope="row" class="asset_number td-clickable">AN20160913111946</th>
<td>Desktop</td>
<td>Dell 0604</td>
<td>SN60609072016</td>
<td class="bundle_asset_id td-clickable"></td>
<td class="asset_status ">Assigned Permanent</td>
<td class="status_effectivity td-clickable">2016-09-10</td>
<td class="asset_user td-clickable">Admin Manager</td>
<td class="asset_location td-clickable">PICUP4FCA</td>
<td>Best</td>
<td class="asset_inventory td-clickable">2016-09-12</td>
<td class="hide asset_id">29</td>
<td class="hide can_be_parent">1</td>
</tr><tr role="row" class="even">
<th scope="row" class="asset_number td-clickable">AN20160913114152</th>
<td>Desktop</td>
<td>Dell 0604</td>
<td>SN60609072016</td>
<td class="bundle_asset_id td-clickable"></td>
<td class="asset_status ">Assigned Permanent</td>
<td class="status_effectivity td-clickable">2016-09-10</td>
<td class="asset_user td-clickable">Admin Manager</td>
<td class="asset_location td-clickable">PICUP4FCA</td>
<td>Best</td>
<td class="asset_inventory td-clickable">2016-09-12</td>
<td class="hide asset_id">30</td>
<td class="hide can_be_parent">1</td>
</tr></tbody>
Here is what I have tried so far:
String selectedAsset = dataTable.getData("AssetNumberToUpdate");
WebElement selectedAssetWE = driver.findElement(By.xpath("//th[contains(.,'" + selectedAsset + "')]"));
selectedAssetWE.click();
I have no problem clicking other web element in my automation but with this scenario I can't really seems to click it. I have a feeling that my problem lies in my Xpath. I'm not quiet experienced in Xpath.