如何单击 UFT 中航班预订应用程序的 Wpf 日历中的特定行
How to click a particular Row in WpfCalendar of Flights Reservation Application in UFT
根据需要,我想 select 下面显示的 FlightsGrid 图像的第二行。
应用下面的代码,我得到的 RowCount 为 6,但无法点击第 3 行。
Set ODesc = Description.Create
oDesc("micclass").value = "WpfTable"
Set objchild = WpfWindow("HPMyFlightSampleApplication").WpfTable("Table_FlightsGrid")
objCount = objchild.rowcount
objCount(2).click
来自航班预订申请的图片:
WpfTable
对象不是集合,它不支持索引。您是否尝试使用其 SelectRow
方法?
首先,如果您能够获得 table 的行数,为什么还要在此处使用 DP。
以下两行将为您提供 table 的行数:
Set objchild = WpfWindow("HPMyFlightSampleApplication").WpfTable("Table_FlightsGrid")
objCount = objchild.rowcount
其次,尝试使用其 SelectRow 方法 select 所需的行。
正如@Motti 所建议的,您可以这样使用 SelectRow
. Or if you want to go more in depth and want to select particular cell (which will eventually select the entire row), you can use SelectCell
:
'Rows and Columns indexes are 0-based
iCols = WpfWindow("devname:=HPE MyFlight Sample Application").WpfTable("devname:=flightsDataGrid").ColumnCount
iRows = WpfWindow("devname:=HPE MyFlight Sample Application").WpfTable("devname:=flightsDataGrid").RowCount
sFlightNum = "12274 NW"
For i = 0 To iRows
If WpfWindow("devname:=HPE MyFlight Sample Application").WpfTable("devname:=flightsDataGrid").GetCellData(i, 4) = sFlightNum Then
WpfWindow("devname:=HPE MyFlight Sample Application").WpfTable("devname:=flightsDataGrid").SelectCell i, 4
Exit For
End If
Next
截图如下:
根据需要,我想 select 下面显示的 FlightsGrid 图像的第二行。 应用下面的代码,我得到的 RowCount 为 6,但无法点击第 3 行。
Set ODesc = Description.Create
oDesc("micclass").value = "WpfTable"
Set objchild = WpfWindow("HPMyFlightSampleApplication").WpfTable("Table_FlightsGrid")
objCount = objchild.rowcount
objCount(2).click
来自航班预订申请的图片:
WpfTable
对象不是集合,它不支持索引。您是否尝试使用其 SelectRow
方法?
首先,如果您能够获得 table 的行数,为什么还要在此处使用 DP。 以下两行将为您提供 table 的行数:
Set objchild = WpfWindow("HPMyFlightSampleApplication").WpfTable("Table_FlightsGrid")
objCount = objchild.rowcount
其次,尝试使用其 SelectRow 方法 select 所需的行。
正如@Motti 所建议的,您可以这样使用 SelectRow
. Or if you want to go more in depth and want to select particular cell (which will eventually select the entire row), you can use SelectCell
:
'Rows and Columns indexes are 0-based
iCols = WpfWindow("devname:=HPE MyFlight Sample Application").WpfTable("devname:=flightsDataGrid").ColumnCount
iRows = WpfWindow("devname:=HPE MyFlight Sample Application").WpfTable("devname:=flightsDataGrid").RowCount
sFlightNum = "12274 NW"
For i = 0 To iRows
If WpfWindow("devname:=HPE MyFlight Sample Application").WpfTable("devname:=flightsDataGrid").GetCellData(i, 4) = sFlightNum Then
WpfWindow("devname:=HPE MyFlight Sample Application").WpfTable("devname:=flightsDataGrid").SelectCell i, 4
Exit For
End If
Next
截图如下: