Stuck - Need help !
I'm trying to automate actioning items in an IE web page on our internal company site. I'm able to fill out any kind of text object, click on a submit button etc., but several items are either in a grid/table (Kendo Grid) or a dropdown list. I just can't seem to figure out how to select from these grids/tables or dropdowns.
I've tried everything I can think of, to no avail. I've used getElementById()
, getElementsByTagName()
, getElementsByName()
, and even some web scraping techniques.
Unfortunately, as the web page is on an internal site, no one else will be able to test against it.
This is the main part of my code
'After opening the web page, inserting a number, selecting the "search"
' (all from the VBA script), I have to use a "mousemove", "mousedown" and
' "mouseup" to select the item, whick is what the "myClick" subroutine does
myClick '<<< THIS IS WHAT I WANT TO GET RID OF >>>
'I left the following segment in to show that I'm able to do several other functions
myDocs = ie.Document.getElementById("DispatchComments").Value
If myInfo = True Then
ie.Document.getElementById("DispatchComments").Value = "__" & myCell5 & "__" & myDocs
Else: End If
'IF ESTIMATED TIME IS LESS THAN 0, ENTER 120 - Enter estimated time
If ie.Document.getElementById("TotalEstimatedTime").Value < 10 Then
ie.Document.getElementById("TotalEstimatedTime").Value = 120
Else: End If
End With
End Sub
`
This is a screen shot after entering the lease number and clicking the search button. The only way I've managed to select the row is to programmatically click the mouse in one of the three white-background areas shown. My code uses mousemove
and coordinates to select the row, scroll down to a tank dropdown and click it open so I can manually choose a tank number.
This portion of the code is where I'm stuck
Set myChoice1 = ie.Document.getElementById("drgdLease").getElementsByTagName("tr")(1)
With myChoice1
.getElementsByTagName("td")(0).Focus '<<---Works all the way to here
.FireEvent ("onmouseover") '<<---No errors from this point on
.FireEvent ("onmousedown") 'but doesn't do anything
.FireEvent ("onmouseup")
.FireEvent ("onclick") '<<---some other things tried
.FireEvent ("ondblclick")
.FireEvent ("onselect")
td.innerText = value
td.innerHTML = value
End With
'<tr role="row" data-uid="db62d811-4337-477c-a0fd-0e9e036670bb">
' <td role="gridcell">998262</td> '<<---This is the info/row I need to select
' <td role="gridcell">HENDERSON (SMACKOVER) STORAGE</td>
' <td role="gridcell">ORYAN OIL & GAS</td>
Inspecting the element for the area I'm trying to select shows this HTML
name="Result">
<div class="k-widget k-grid" id="drgdLease" style="-ms-touch-action: double-tap-zoom pinch-zoom;" data-role="grid">
<table class="k-selectable" role="grid" style="-ms-touch-action: double-tap-zoom pinch-zoom;" data-role="selectable">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead class="k-grid-header" role="rowgroup">
<tr role="row">
<th class="k-header k-with-icon" scope="col" data-title="Lease Number" data-index="0" data-field="LeaseCode" data-role="columnsorter">
<a tabindex="-1" class="k-header-column-menu" href="#">
<span class="k-icon k-i-arrowhead-s"></span>
</a>
<a class="k-link" href="/LeaseProfiles/GetLeasesSearch?Length=9&drgdLease-sort=LeaseCode-asc">Lease Number</a>
</th>
<th class="k-header k-with-icon" scope="col" data-title="Lease Name" data-index="1" data-field="LeaseName" data-role="columnsorter">
<a tabindex="-1" class="k-header-column-menu" href="#">
<span class="k-icon k-i-arrowhead-s"></span>
</a>
<a class="k-link" href="/LeaseProfiles/GetLeasesSearch?Length=9&drgdLease-sort=LeaseName-asc">Lease Name</a>
</th>
<th class="k-header k-with-icon" scope="col" data-title="Lease Operator" data-index="2" data-field="LeaseOperator.OperatorName" data-role="columnsorter">
<a tabindex="-1" class="k-header-column-menu" href="#">
<span class="k-icon k-i-arrowhead-s"></span>
</a>
<a class="k-link" href="/LeaseProfiles/GetLeasesSearch?Length=9&drgdLease-sort=LeaseOperator.OperatorName-asc">Lease Operator</a>
</th>
</tr>
</thead>
<!--
This is what the code looks like before selecting the item.
ie: before clicking anywhere on the row.
-->
<tbody role="rowgroup">
<tr role="row" data-uid="db62d811-4337-477c-a0fd-0e9e036670bb">
<td role="gridcell">998262</td>
<td role="gridcell">HENDERSON (SMACKOVER) STORAGE</td>
<td role="gridcell">ORYAN OIL & GAS</td>
</tr>
</tbody>
</table>
<!--
This is what the code changes to after clicking the row.
Note the class and arial are added on the `tr role` line, which may be binding the data.
-->
<tr role="row" data-uid="db62d811-4337-477c-a0fd-0e9e036670bb" class = "k-state- selected" arial = "true">
<td role="gridcell">998262</td>
<td role="gridcell">HENDERSON (SMACKOVER) STORAGE</td>
<td role="gridcell">ORYAN OIL & GAS</td>