Select a list item from a combobox

Ask general questions here.
CarlaNeves
Posts: 14
Joined: Thu Feb 26, 2009 2:08 pm

Select a list item from a combobox

Post by CarlaNeves » Tue Mar 17, 2009 12:22 pm

Hi there,

I can't select a list item from a regular .net combobox. Here's the code I used:

Code: Select all

Ranorex.ComboBox ComboBox = "/form[@controlname='FRM_Main']/container/element/*/*/container[@caption='' and @processname='MyApplication' and @controltypename='WindowDockingArea' and @class='WindowsForms10.Window.8.app.0.11c7a8c' and @instance='0']/container[@caption='' and @processname='MyApplication' and @controltypename='DockableWindow' and @class='WindowsForms10.Window.8.app.0.11c7a8c' and @instance='0']/*/container[@controlname='panel1']/element[@controlname='comboSite']/*/combobox";
    
// Open combobox by clicking the
// drop down button
Ranorex.Button open = ComboBox.FindChild<Ranorex.Button>("Open");
open.Click();

// Select list item
// from DropDown list
ListItem listItem = ComboBox.FindSingle<ListItem>
("/form[@controlname='FRM_Main']/container/element/*/*/container[@caption='' and @processname='MyApplication' and @controltypename='WindowDockingArea' and @class='WindowsForms10.Window.8.app.0.11c7a8c' and @instance='0']/container[1]/*/container[@controlname='panel1']/element[@controlname='comboSite']/combobox/*/list/listitem[@accessiblename='4270' and @accessiblerole='ListItem' and @text='4270' and @index='12']");

listItem.Click();
The list item never gets into the "Selected" state, not even when explicitly set, therefore i cannot proceed with the automation process.

Can someone help me on this?

Thank you very much,
Carla Neves

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Select a list item from a combobox

Post by Support Team » Tue Mar 17, 2009 2:54 pm

CarlaNeves wrote:The list item never gets into the "Selected" state ...
Do you mean that the list item is never clicked or that the value of the "Selected" attribute (in RanorexSpy) is never set to True?
Is the mouse moving to the right position?

Regards,
Alex
Ranorex Support Team

CarlaNeves
Posts: 14
Joined: Thu Feb 26, 2009 2:08 pm

Post by CarlaNeves » Tue Mar 17, 2009 6:11 pm

The item is never clicked, and the mouse cursor jumps into the top left corner of the screen.


Thanks in advance,
Carla Neves

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Post by Ciege » Tue Mar 17, 2009 7:52 pm

This sounds eerily similar to the issue I am having with the .click() method of ATag and InputTag using the DOM. My issue also results in the cursor moving to 0,0 or 1,1 of the screen.
Hmmm....

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Wed Mar 18, 2009 11:32 am

Carla,
We are currently working on a solution.
Does this occur randomly or every time you execute your test ?

@Ciege
You are right, this is probably the same issue.
It seems the problem is not caused by the Web plugin itself.

CarlaNeves
Posts: 14
Joined: Thu Feb 26, 2009 2:08 pm

Post by CarlaNeves » Wed Mar 18, 2009 2:07 pm

Hi there,

Unfortunately this occur every time I execute the test.

Thank you,
Carla Neves

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Wed Mar 18, 2009 4:01 pm

Hi,

Could you output listItem.ScreenRectangle and listItem.ClientRectangle before calling Click() and post the results ?

Thanks,
Michael
Ranorex Team

CarlaNeves
Posts: 14
Joined: Thu Feb 26, 2009 2:08 pm

Post by CarlaNeves » Wed Mar 18, 2009 5:19 pm

Hello,

The output from listItem.ScreenRectangle is {X=0,Y=0,Width=0,Height=0}.
The ClientRectangle is only available through the property Element.
The output from listItem.Element.ClientRectangle is {X=0,Y=0,Width=0,Height=0}.



Thank you,
Carla Neves

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Mon Mar 23, 2009 10:33 am

From our research it seems that these two problems do not have more in common than the empty ScreenRectangle. Carla reported that problem with a .Net ComboBox, Ciege with DOM (web) elements. With both technologies the element reports an empty ScreenRectangle if some internal error occured.

For DOM elements we could reproduce that problem and we know that an internal security exception is the primary cause. We are trying to implement a workaround for that.

We couldn't reproduce Carla's problem concerning the list items in a .NET ComboBox, though.
@Carla, is this combobox a standard System.Windows.Forms.ComboBox? Would it be possible to get a sample application with that combobox and your automation code (to support_at_ranorex.com)?

Regards,
Alex
Ranorex Support Team

CarlaNeves
Posts: 14
Joined: Thu Feb 26, 2009 2:08 pm

Post by CarlaNeves » Mon Mar 23, 2009 12:27 pm

Hi!

The combobox is a Infragistics.Win.UltraWinEditors.UltraComboEditor.

I did a test with a System.Windows.Forms.ComboBox and works fine with the following code:

Code: Select all

Ranorex.ComboBox ComboBox1 = "/form[@controlname='Form1']/combobox";
ComboBox1.Element.SetAttributeValue("Text", "Item 3");
Thank you,
Carla Neves

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Mon Mar 23, 2009 1:30 pm

Seems like the implementation of the Infrgistics UltraComboEditor is broken, the list items all return an empty ScreenRectangle. As a workaround you could use the keyboard to select the items in the dropdown list:

Code: Select all

ComboBox infragisticsComboEditor = ...;
Button dropDownButton = infragisticsComboEditor.FindChild<Button>();
foreach (ListItem item in infragisticsComboEditor.Items)
{
    // open the drop-down
    dropDownButton.Click();
    // select the first item using the Home key
    Keyboard.Press(System.Windows.Forms.Keys.Home);
    // press the Down key to get to the right item
    if (item.Index > 0)
        Keyboard.Press(System.Windows.Forms.Keys.Down, Keyboard.DefaultKeyPressTime, item.Index);
    // select the item using the Enter key
    Keyboard.Press(System.Windows.Forms.Keys.Enter);
    Delay.Ms(1000);
}
Regards,
Alex
Ranorex Support Team