Alice P_ Immanuel Absent Member.
Absent Member.
710 views

Choosing a value from list box

Jump to solution

Hi,

I am trying to pick a value from list box which contains a string. I don't have the exact/ full value present in the drop down.

 Eg:

desktop.<DomListBox> find("object01").select("Working on silk");

Here I wont be knowing the entire String value -"Working on silk", so I want to chose the string which has "silk", How to achieve that?

 

 

Thanks,

Alice

Tags (2)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Contributor
Micro Focus Contributor

RE: Choosing a value from list box

Jump to solution
Hi,


1) If you know where the item appears in the list then you can easily use an index to select the value from the Listview, like so:

With _desktop.Window("@caption='Test Application'")
With .Dialog("@caption='List View'")
.SetActive()
.ListView("@caption='The List View'").Select(0)

End With

Where 0 is the first item in the list, where 1 is the second and so on or you can use a wildcard for the string value.

2) You can also return all of the items in the list and then do whatever you wish to do based on this. In the example below I am iterating through the list, returning the string and then if it matches the criteria where it contains specific characters then it is selected, like so:

Dim sItems As New List(Of String)
sItems = .ListView("@caption='The List View'").Items

For Each sItem As String In sItems
Console.WriteLine(sItem)
If sItem.Contains("Hor") Then
.ListView("@caption='The List View'").Select(sItem)
End If
Next


Thanks,
John
0 Likes
3 Replies
Highlighted
Micro Focus Contributor
Micro Focus Contributor

RE: Choosing a value from list box

Jump to solution
Hi,


1) If you know where the item appears in the list then you can easily use an index to select the value from the Listview, like so:

With _desktop.Window("@caption='Test Application'")
With .Dialog("@caption='List View'")
.SetActive()
.ListView("@caption='The List View'").Select(0)

End With

Where 0 is the first item in the list, where 1 is the second and so on or you can use a wildcard for the string value.

2) You can also return all of the items in the list and then do whatever you wish to do based on this. In the example below I am iterating through the list, returning the string and then if it matches the criteria where it contains specific characters then it is selected, like so:

Dim sItems As New List(Of String)
sItems = .ListView("@caption='The List View'").Items

For Each sItem As String In sItems
Console.WriteLine(sItem)
If sItem.Contains("Hor") Then
.ListView("@caption='The List View'").Select(sItem)
End If
Next


Thanks,
John
0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Choosing a value from list box

Jump to solution

Hi Alice,

You can also use the wildcards * (matches 0-n characters) and ? (matches one character) here. Example:

desktop.<DomListBox> find("object01").select("*silk");

Regards, Michael

0 Likes
Alice P_ Immanuel Absent Member.
Absent Member.

RE: Choosing a value from list box

Jump to solution

It wont accept that way. It will treats '*' as another letter in the string.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.