| View previous topic :: View next topic |
| Author |
Message |
issamq
Joined: 19 Apr 2007 Posts: 4
|
Posted: Thu Apr 19, 2007 2:11 am Post subject: Unable to cast object of type 'Ranorex.Control' to ComboBox |
|
I am getting this message when I try to cast ComboBox to the Control type.
Unable to cast object of type 'Ranorex.Control' to type 'Ranorex.ComboBox'.
Code: click into code to enlarge
Control curComboBox = form.FindControlName(curControl.Name);
ComboBox curCmbBox = (ComboBox)curComboBox;
|
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Thu Apr 19, 2007 11:45 pm Post subject: |
|
I tried this in V1.1.0 and it worked.
Which Ranorex and .NET Framework version do you use?
I would suggest the following function:
ComboBox comboBox = form.FindComboBox(curControl.Name);
Jenö
Ranorex Team |
|
| Back to top |
|
 |
issamq
Joined: 19 Apr 2007 Posts: 4
|
Posted: Thu Apr 19, 2007 11:50 pm Post subject: |
|
I have already what you suggested and I got back null.
I am using the latest version of your tool: v1.1.0 along with .Net 1.1 and DevExpress controls. |
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Sun Apr 22, 2007 4:00 pm Post subject: |
|
You can't use the Ranorex.ComboBox class for DevExpress ComboBox.
I made some tests with the "XtraGrid Features Demo" of the DevExpress demo application. You can automate the DevExpress controls with the Element functionality.
The following code automates a DevExpress ComboBox(from the TableLayout page):
Code: click into code to enlarge
Control newItemCombobox = form.FindControlName("icbNewItemRow");
if (newItemCombobox == null)
{
Console.WriteLine("Cannot find icbNewItemRow");
return 1;
}
Mouse.ClickControl(newItemCombobox);
Element listItem = newItemCombobox.Element.FindChild(Role.ListItem, "Top");
if (listItem == null)
{
Console.WriteLine("Cannot find listItem");
return 1;
}
Mouse.ClickElement(listItem);
Gabor
Ranorex Team |
|
| Back to top |
|
 |
issamq
Joined: 19 Apr 2007 Posts: 4
|
Posted: Mon Apr 23, 2007 9:03 pm Post subject: |
|
That still did not work. Currently my work around is to use the sendKey to set the value of the combo box. The workaround you outlined which is using the Element is not finding the Listitem object. I looped through the Elements contained in the control, and none of them is a listitem.
Can I assume that your product does not support DevExpress controls? |
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Mon Apr 23, 2007 9:27 pm Post subject: |
|
I think the ListItems will be generated after a drop down operation.
You should wait a little bit after clicking on the combobox.
Try the following modified code:
Code: click into code to enlarge
Control newItemCombobox = form.FindControlName("icbNewItemRow");
if (newItemCombobox == null)
{
Console.WriteLine("Cannot find icbNewItemRow");
return 1;
}
Mouse.ClickControl(newItemCombobox);
Application.Sleep(200);
Element listItem = newItemCombobox.Element.FindChild(Role.ListItem, "Top");
if (listItem == null)
{
Console.WriteLine("Cannot find listItem");
return 1;
}
Mouse.ClickElement(listItem);
Which DevExpress version do you use? I made the tests with the v7.1.
| Quote: |
| Can I assume that your product does not support DevExpress controls? |
Ranorex's Element approach works with almost every custom controls(e.g. DevExpress).
If not please send us a simple application.
Gabor
Ranorex Team |
|
| Back to top |
|
 |
issamq
Joined: 19 Apr 2007 Posts: 4
|
Posted: Wed Apr 25, 2007 2:08 am Post subject: |
|
| And to email address to email the sample app to? |
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Wed Apr 25, 2007 8:50 am Post subject: |
|
Please send the sample app to: gherget(at) ranorex.com
Gabor
Ranorex Team |
|
| Back to top |
|
 |
|