Quantcast
Channel: Silk Test - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 625

How to Find next element ,if it exists

$
0
0

Hi All,

I have WPFListView and want to locate WPFListviewitem ( List of names ). I want to get text of all the names.
FindAll function does not work becuase for long list elements in the end of list get disconnected.

Using below code I get most of the elements but not all.

Question: How can I get all elements in the list i.e. is there any way I can keep looking until there is a element(WPFListviewitem) on the screen present? I dont know the exact locator as names/some other values are dynamically created.

Code: Following code gets me most of elements in the WPFListView but not all

        <  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 sObjSublocator As String = "//WPFToggleButton[@caption='*']"                       

                        Dim iRow As Integer = 0
                       Agent.SetOption(Options.WpfPrefillItems, False)

                       Dim values As List(Of String ) = New List(Of String)

                       Do While ( iRow <= 510 ) 'loop untill end of list ,510 works and can add logic to find end of loop

                       Dim rows As IList = _desktop.WPFListView(sObjlocator).FindAll(sObjSublocator)

                       For Each row As WPFToggleButton In rows
                               Dim sString As String = row.Text
                               Console.WriteLine("sString {0}: " ,sString ) 'names

                               If String.IsNullOrEmpty(sString) Then
                                    Console.WriteLine("Empty string ")
                                    iSumPosition += iPosition
                                  
                                   iRow = iRow + 1
                                   _desktop.WPFListView(sObjlocator).ScrollToPosition(iSumPosition, Orientation.Vertical)
                                   Exit For
                            Else
                                    values.Add(sString)
                                    iSumPosition += iPosition
                                    iRow = iRow + 1
                                   _desktop.WPFListView(sObjlocator).ScrollToPosition(iSumPosition, Orientation.Vertical)
                        End If

                  Next
                    rows.Clear()
                    Console.WriteLine("Start Next Loop")
             Loop

             PrintValues(values)
              
             Dim result As List(Of String) = values.Distinct().ToList ' Get only distinct elements in list

             PrintValues(result)

            End Sub

               Public Sub PrintValues(myList As IEnumerable)
                      Dim obj As [Object]
                      For Each obj In myList
                      Console.Write(" {0}", obj)
               Next obj
Console.WriteLine()
End Sub 'PrintValues
End Module

>

Tokci


Viewing all articles
Browse latest Browse all 625

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>