I need to scroll to an element present in table for a WPF application, the value is dynamically provided during run time.
I have below code which runs fine for small listview as scrollbar moves correctly but does not scroll to elements near the end of a long list.
My list is as below and I scroll using names (A1
, A2
, ...)
A1 1 3
A2 1 5
S1 1 3
Q2 1 5
.....
.....
Z7 1 3
Z82 1 5
Z9 1 3
Imports SilkTest.Ntf.Wpf
Public Module Main
Dim _desktop As Desktop = Agent.Desktop
Public Sub Main()
Dim iPosition As Double = 0.5
Dim iSumPosition As Double = 0.0
Dim sObjlocator As String = "//WPFListView[@automationId='MyListView']"
Dim sData As String = "Z118"
Dim sObjSublocator As String = "//WPFToggleButton[@caption='*']"
Dim rows As IList = _desktop.WPFListView(sObjlocator).FindAll(sObjSublocator)
Dim sObjExist As Boolean = False
For Each row As WPFToggleButton In rows
Dim sString As String = row.Text
Console.WriteLine(sString) ' <--names
If Trim(sString) = sData Then
sObjExist = True
Exit For
Else
iSumPosition += iPosition
Console.WriteLine(iSumPosition) ' <--Position
_desktop.WPFListView(sObjlocator).ScrollToPosition(iSumPosition, Orientation.Vertical)
End If
Next
End Sub
End Module
Issue:
As shown in the output below, the printed lines A1
, A10
, ... from Console.WriteLine(sString)
and the numbers from Console.WriteLine(iSumPosition)
, works only for a few objects off-screen, the scrollbar moves vertically down, but if my list is large and I need scroll many times then scrolling doesn't work any more.
The scroll bar does not scroll to the end for names near the end of the list, only if my list is very small then it scrolls down to very last element as well.
In Debug mode I see that the rows list (Dim rows As IList = _desktop.WPFListView(sObjlocator).FindAll(sObjSublocator)
) does not have the values (names) for elements near the end of the list.
In the output below, we can see names and positions are printed initially but near the end of the long list only positions are printed.
Output:
A1
0.5
A10
1
A11
1.5
A12
2
...
...
...
9.5
10
10.5
Additional info:
- Locator type is WPFScrollBar.
- WPF pre-fill forms settings in SilkTest is : yes
- Using automation testing tool : Microfocus SilkTest 17.5