unable to select a listitem

Oct 29, 2010 at 12:56 AM

 

 

I am unable to select an item from the listbox. Can someone please help. Thanks.

L

istBox lb = myWindow.Get<ListBox>(SearchCriteria.ByAutomationId("timeComboBox")

));

lb.Items[4].Select();

 Also tried

 lb.Items[4].Click()

 

I could get the selected item using the code however i am not able to select any item

var

item = lb.Items.Where(p => p.IsSelected).First();

 

 

MessageBox.Show("Selected: "+ item.Name.ToString());

Oct 29, 2010 at 6:58 AM

Hi

is it right, that you want to select a value from a combobox? (I think that because of the automation ID)

 

than you should use:

 

WPFComboBox cb = myWindow.Get<WPFComboBox>(SearchCriteria.ByAutomationId("timeComboBox");

 

You can use cb.Select(<name of the item>); if this works stable for you

 

In most cases I use

 

WPFComboBox cb = myWindow.Get<WPFComboBox>(SearchCriteria.ByAutomationId("timeComboBox");

cb.Click();

ListItem item  = cb.Items.Where(p=p.Name == "name").First();

item.Click();


Throndorin

 

 

 

 

 

Oct 29, 2010 at 1:20 PM

It is a listbox and i want to select a list item. It's not a combo b ox.

Oct 29, 2010 at 2:45 PM

ok :)

 

beat the developer, the automatio ID says something other. :)

 

is the Listitem visible and enabled at the point of time you call click() ? (maybe your test is to fast)

use a Thread.Sleep(5000) for example before you perform the click();

and the same after

have a look on the item, does the mouse points to the correct position.

 

We should try to isolate the problem first :)

 

Throndorin