FlexElement method usage on FlexDataItem?

Class library usage, coding and language questions.
swambach
Posts: 7
Joined: Tue Oct 19, 2010 6:31 pm

FlexElement method usage on FlexDataItem?

Post by swambach » Tue Oct 19, 2010 6:36 pm

I have a flex application with a treeview in it. The treeview items sometimes change their color to represent something different (e.g. colored red when they're not editable).

I'd like to try to access what I believe to be a color property of the object, but it seems that the GetStyle and GetPropertyValue methods are only available on the FlexElement types. I'm only able to represent my tree item as a FlexDataItem (which doesn't seem to have the property interrogation methods).

Any ideas on a workaround?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: FlexElement method usage on FlexDataItem?

Post by Support Team » Thu Oct 21, 2010 1:56 pm

Hi,

Please can you post us a Ranorex Snapshot of your tree?
How to create a snapshot...

Another solution would be to use the As Method of Ranorex. Please try following code for FlexDataItem
FlexDataItem item = "RxPath";
item.As<FlexElement>().GetStyle("param");
Regards,
Peter
Ranorex Team
.
Image

swambach
Posts: 7
Joined: Tue Oct 19, 2010 6:31 pm

Re: FlexElement method usage on FlexDataItem?

Post by swambach » Thu Oct 21, 2010 2:11 pm

Hi Peter,

It's a proprietary application; is there a non-public way that I could post the snapshot (outside of this forum)?

I've tried the As<FlexElement> method, but haven't had any success. It's been returning null (presumably not able to convert the data item of the tree. I can convert other objects [such as buttons, etc], but not children of the object - like data items in a tree). Here's an example:

Code: Select all

FlexDataItem fDA = repo.WebDocumentHashlocalName.TreeItem.As<FlexDataItem>();  <--This works
FlexElement flexEl = repo.WebDocumentHashlocalName.TreeItem.As<FlexElement>();   <--This does not

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: FlexElement method usage on FlexDataItem?

Post by Support Team » Thu Oct 21, 2010 2:25 pm

Hi,

Please send us the Ranorex Snapshot to our support mailbox.
[email protected]

Thanks in advance.

Regards,
Peter
Ranorex Team
.
Image

swambach
Posts: 7
Joined: Tue Oct 19, 2010 6:31 pm

Re: FlexElement method usage on FlexDataItem?

Post by swambach » Thu Oct 21, 2010 2:46 pm

Sent.

Thanks!

FloNeu
Posts: 5
Joined: Thu Jan 13, 2011 3:07 pm

Similar Problem!

Post by FloNeu » Thu Jan 13, 2011 3:53 pm

Was there a solution for this problem?
I am trying to automate the testing of a flex/air application and ran into similar problems.

In general i have some problems understanding the handling of list-elements in Ranorex.

If i access the listitem over the repository Ranorex tells me that this listItem is a FlexDataItem
of type WorkitemVo (that is the Type of the data-objects contained in the lists dataprovider)
I can now iterate ofer the listsItems(mylist.ITEMS) and cast them to FlexDataItems.
If i access the listItems by using mylist.CHILDREN i only get Ranorex.Unkown-Elements.
Both classes can't be casted to a FlexElement who possibly would have the methodes
to access the contained Properties.

As far as i understand the FlexElement-Class ist meant to represent Flex UIComponents/Elements
while the description of FlexDataItem states that this element is part of a data-component like
an Flex-ArrayCollection. But what use has this FlexDataItem-class if it doesn't enable me
to access the properties of this VO?

As Flex-Developer i would Ranorex expect to deliver FlexElements (The ItemRenderer-Components) when using myList.CHILDREN and an ACCESSABLE FlexDataItem when using myList.ITEMS...

I am now trying to access the ListData for hours... Do you have any suggestions?

All the best, Florian

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: FlexElement method usage on FlexDataItem?

Post by Support Team » Fri Jan 14, 2011 1:40 pm

Hi,

I talked to one of our Flex developers and he said it is currently not possible, sorry. We added your issue as feature request to our internal bug tracking tool and we will release a solution for this problem in a future version of Ranorex, but I cannot tell you an exact date when this will be.

Regards,
Peter
Ranorex Team
.
Image

FloNeu
Posts: 5
Joined: Thu Jan 13, 2011 3:07 pm

Re: FlexElement method usage on FlexDataItem?

Post by FloNeu » Mon Jan 17, 2011 8:26 am

Thanks for your efforts... Not what i hoped for, but i have to find another way then.

Allow me to make some other remarks on your flex-version:
Another problem i ran into is that while iterating over the listitems
(mylist.items) is that there is no access to the FlexDataItems not contained in
and visible itemrenderer resulting in an 'Out of bounds'-Exception.
Like:
//In case there is a flex-tilelist with 8 itemrenderers
//and a dataprovider containing more elements
for(int i = 0; i < mylist.items.length; i++)
{
FlexDataItem workItem = mylist.items;
//throws "Out of bounds" on i = 8
}

Also Ranorex seems to lose the repo. ref on rerendering of Flex-Components.
Example: I always use the RepoInfo-Objects exists-Methode before performing
a click or similar on a component. But sometimes it just doesn't work... Ranorex
returns true on exist (The component is also visible on the screen), but when the
mouse click should be performed it somehow can't find the correct position and clicks
in the top-left corner of the screen. This behaviour is really anoying because i don't
know how to reproduce it, it just happens from time to time and i now need to
loop and check after every click to make sure the programm keeps running until
the end.

All the best, Florian

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: FlexElement method usage on FlexDataItem?

Post by Support Team » Mon Jan 17, 2011 5:24 pm

Hello Florian,

Regarding your first issue:
The list should always contain all items from the data provider. If there is an itemrenderer available for the data item, it should have valid geometry data (visible, rectangle, etc.).
I have tried with a tile list to reproduce your problem, with
List myList = "/dom[@page='FlexExample.html']/body/flexobject/list";
for(int i=0; i<myList.Items.Count;i++)
{
     FlexDataItem item = myList.Items.As<FlexDataItem>();
     //...
}

but that yields all 13 items of the list with 8 being visible (i also recommend using foreach(var item in myList.Items) instead)

Regarding your second issue:
The item is probably in a folder which is cached, and if the container element is recreated without being removed by the flash VM it might still be valid. I would suggest disabling caching (properties -> UseCache)
in the repository folders containing the element.
Exists() only means that the item is available, but not necessarily visible.

Michael
Ranorex Team
.
Image

FloNeu
Posts: 5
Joined: Thu Jan 13, 2011 3:07 pm

Re: FlexElement method usage on FlexDataItem?

Post by FloNeu » Thu Jan 20, 2011 2:12 pm

No, that's not right for my case...
I have a tilelist with a scrollbar, there is only one row containing 8 items visible...
I iterate over the listitems using a foreach() after 8 items this exception is thrown:

2011/01/20 13:59:06.679 ERROR User Unexpected exception occured: System.ArgumentOutOfRangeException: Der Index lag außerhalb des Bereichs. Er muss nicht negativ und kleiner als die Auflistung sein.
Parametername: index
bei System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
bei System.ThrowHelper.ThrowArgumentOutOfRangeException()
bei System.Collections.Generic.List`1.get_Item(Int32 index)
bei RedBullBP_Login.Actions.RedBull_Client_HomeScreenActions.getWorkItemby(String region, String shortCountry, String bundleName)
bei RedBullBP_Login.Actions.RepeatedActions.delayUntilWorkitemExists(String region, String country, String bundleName, Double maxDelay)
bei RedBullBP_Login.TestCases.Atf006_Client_CheckWorkitemIsLocked.Run()
bei RedBullBP_Login.TestCases.Atf006_AdminCockpit_Functions.Run()
bei RedBullBP_Login.Program.Main(String[] args)

As you see thats an error occuring in the Ranorex list... That is the code i am using...
foreach(ListItem listItem in repo.FormRed_Bull_BPToolTesting.homeScreen.ListMyWorkItemList.Items)
{
//Error also appears with no code here... Items.Count is 64...
}

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: FlexElement method usage on FlexDataItem?

Post by Support Team » Thu Jan 20, 2011 3:41 pm

Actually, the error is not occurring in the Ranorex list class, but in the .NET Framework List class. This can only happen if you use an index to access the list, not with a foreach statement. Are you sure you changed all for loops to foreach statements? Otherwise this has to be a .NET Framework issue...

Could you post the complete getWorkItemby method that throws this exception?

Regards,
Alex
Ranorex Team
.
Image

FloNeu
Posts: 5
Joined: Thu Jan 13, 2011 3:07 pm

Re: FlexElement method usage on FlexDataItem?

Post by FloNeu » Fri Jan 21, 2011 10:38 am

Yes it's a foreach-loop...

I am not a .Net Developer, but i am sure somebody would have noticed if there would be a bug
in such an essential place.

My view on this issue is that there is an mapping error in Ranorex... As items.Count returns the
correct value of contained dataitems this number has to come from the dataprovider.length.
The loop-breaks after all visible workitems were accessed... this could mean that the Collection containing
the itemrenderers is accessed... this would lead to an outofBounds-Exception, because the itemrenderer-collection only contains 8 items, while the dataprovider contains more...

all the best, Florian

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: FlexElement method usage on FlexDataItem?

Post by Support Team » Fri Jan 21, 2011 11:09 am

FloNeu wrote:I am not a .Net Developer, but i am sure somebody would have noticed if there would be a bug in such an essential place.
I doubt that this is a .NET bug, too :-)

The thing is that the actual data provider returned by the Ranorex.List.Items property is a standard .NET List. The Items property searches for all items in the list control and adds them to a List collection instance. Then this collection is returned. From then on you work on the standard .NET List. So, if the exception occurs within the foreach loop, the exception cannot be caused by the Ranorex.List.Items implementation...

I looked at the code for the Ranorex.List.Items property, but cannot find code that might possible cause the exception. That's why I asked if you could post the complete code for the "getWorkItemby" method.

Regards,
Alex
Ranorex Team
.
Image

FloNeu
Posts: 5
Joined: Thu Jan 13, 2011 3:07 pm

Re: FlexElement method usage on FlexDataItem?

Post by FloNeu » Fri Jan 21, 2011 2:37 pm

I found the problem... you where right... the problem seems to be this
line of code... listItem.Children[0].As<Text>().TextValue.ToString() as i can't access the
Labelfield of the invisible listItems. Annoying behavior...