ColumnIndex of Cell always 0 in Silverlight

Class library usage, coding and language questions.
User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

ColumnIndex of Cell always 0 in Silverlight

Post by Aracknid » Thu May 19, 2011 11:01 pm

Hi,

I wrote some code a while back using an older version of Ranorex (probably v2.3.4) and it was working fine. I left it for a while and recently got back to using Ranorex. When I tried to run the code using the latest version of Ranorex it always returns 0 for the ColumnIndex of my cell.

Here are the details:

- Using VS2010 (not SP1 yet), Ranorex 3.0.1 (API), Silverlight object (Silverlight v4)
- Code is basically like this:
Dim MyRow as Ranorex.Row
Dim MyHeaderCollection as New Collection
For Each MyCell as Ranorex.Cell in MyRow.Cells
    MyHeaderCollection.Add(Mycell.Text, MyCell.ColumnIndex)
Next
It used to add to the collection using the ColumnIndex as key, but since it always returns 0 now, I get an error when trying to add the second item.

When I spy on the Silverlight Object, it shows 0 for the column index for all the cells in the row. I've attached Ranorex Snapshot for you, and a screen shot of the problem in Ranorex Spy.

Please note: The application under test DID change since I last ran, but even so I would have expected it to still work and give me a ColumnIndex.

Thanks,

Aracknid
Attachments
Ranorex Snapshot ColumnIndex Issue.zip
(172.39 KiB) Downloaded 192 times

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

Re: ColumnIndex of Cell always 0 in Silverlight

Post by Support Team » Fri May 20, 2011 11:42 am

Aracknid wrote:When I spy on the Silverlight Object, it shows 0 for the column index for all the cells in the row. I've attached Ranorex Snapshot for you, and a screen shot of the problem in Ranorex Spy.
Actually, the column index might still be correctly evaluated at runtime, it is just not evaluated when shown in Ranorex Spy, since this can be a computational expensive operation and is therefore disabled by default.

Please, try to enable the expensive attributes in Ranorex Spy by unchecking the setting "Disable expensive attributes in tools" in the General Settings -> Advanced. And then try to track the items again and check if the indexes are correctly displayed.

BTW, you might also want to update to the latest release 3.0.2:
http://www.ranorex.com/download.html

Regards,
Alex
Ranorex Team
.
Image

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: ColumnIndex of Cell always 0 in Silverlight

Post by Aracknid » Fri May 20, 2011 8:20 pm

Thanks, I'll try what you mentioned and get back to you, but I was also getting 0 when running in VS2010 and I had a breakpoint at that Add to a collection line.

Aracknid

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: ColumnIndex of Cell always 0 in Silverlight

Post by Aracknid » Fri May 20, 2011 10:48 pm

OK, I unchecked "Disable expensive attributes in tools", or in other words Enabled it and when I spy on the ColumnIndex it now does show the correct value.

However, while running in VS2010 SP1 (I updated to SP1 today) and watching the ColumnIndex (hover over it in debug mode), it is still 0. Do I have to add some code in my script to tell it to Enable expensive attributes?

Thanks,

Aracknid

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

Re: ColumnIndex of Cell always 0 in Silverlight

Post by Support Team » Sat May 21, 2011 7:55 am

Aracknid wrote:However, while running in VS2010 SP1 (I updated to SP1 today) and watching the ColumnIndex (hover over it in debug mode), it is still 0. Do I have to add some code in my script to tell it to Enable expensive attributes?
By default no. If Ranorex Spy shows you the value, it should be the same at runtime, too. Just make sure that you do not set the Ranorex.Plugin.WpfFlavor.Instance.ExpensiveAttributesEnabled property to false anywhere in code and that this setting is also enabled in the Plug-in Specific Settings.

Do you use a standard Ranorex project template? If not, make sure that the main method of your EXE project is marked with the [STAThread] attribute.
If the code is running in a separate thread, make sue it uses the STA model.

Regards,
Alex
Ranorex Team
.
Image

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: ColumnIndex of Cell always 0 in Silverlight

Post by Aracknid » Tue May 24, 2011 2:39 pm

By default no. If Ranorex Spy shows you the value, it should be the same at runtime, too. Just make sure that you do not set the Ranorex.Plugin.WpfFlavor.Instance.ExpensiveAttributesEnabled property to false anywhere in code and that this setting is also enabled in the Plug-in Specific Settings.
The WPF 'Evaluate computationally expensive attributes" setting is 'True' in the Plug-in Specific Settings, and I have not set the property in code at all.
Do you use a standard Ranorex project template? If not, make sure that the main method of your EXE project is marked with the [STAThread] attribute.
If the code is running in a separate thread, make sue it uses the STA model.
I have no idea what this means. I simply started VS2010 and created a console app (I did not use any Ranorex templates, nor do I even see any of them). I don't know what STAThread is. Can you point me somewhere to see if this is the issue? :oops:

Also, I was wondering, initially I had to go into the Spy tool and uncheck the "Disable expensive attributes in tools' setting in order for Spy to see the ColumnIndex. Does this mean that VS2010 would also not see it until I went into Spy and did this? Do the changes made in Spy settings impact the behaviour/code being written in VS2010? Also, do I need to restart VS2010 after making changes?

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

Re: ColumnIndex of Cell always 0 in Silverlight

Post by Support Team » Tue May 24, 2011 5:29 pm

Aracknid wrote:Can you point me somewhere to see if this is the issue?
Please, read the Visual Studio Integration topic in the Ranorex User Guide that explains where to put the STAThread attribute. I guess that will fix the problem.
Aracknid wrote:Does this mean that VS2010 would also not see it until I went into Spy and did this?
No, this setting only disables expensive attributes to show up in Ranorex tools (Spy, Recorder). They are evaluated anyway when executing Ranorex code.

Regards,
Alex
Ranorex Team
.
Image

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: ColumnIndex of Cell always 0 in Silverlight

Post by Aracknid » Tue May 24, 2011 6:41 pm

No, this setting only disables expensive attributes to show up in Ranorex tools (Spy, Recorder). They are evaluated anyway when executing Ranorex code.
Well, this is odd. I didn't do anything as suggested above yet, but before you replied I closed my Solution in VS2010 and re-opened it and suddenly it is working. I thought I must be right about the Spy settings being used by VS2010. Now I read the above, and so I went back into Spy and checked the box to turn on the Disable Expensive Attributes feature and it no longer works.

It appears to me that I can go into Spy and control whether or not I can see the ColumnIndex of my Silverlight app in VS2010 by turning this checkbox off and on. I've done it a few times to make sure.

Note that I did not do anything with STAThread.

Any thoughts?

Aracknid

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

Re: ColumnIndex of Cell always 0 in Silverlight

Post by Support Team » Thu May 26, 2011 12:56 pm

Hi,
Aracknid wrote:Any thoughts?
Would it be possible to send or post us your Ranorex Project to check if there are "weird" things in it? Maybe you can send us the application under test too, so we can reproduce this issue.
Aracknid wrote:Note that I did not do anything with STAThread.
But you added this attribute to your code?

Regards,
Peter
Ranorex Team
.
Image

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: ColumnIndex of Cell always 0 in Silverlight

Post by Aracknid » Thu May 26, 2011 3:07 pm

Would it be possible to send or post us your Ranorex Project to check if there are "weird" things in it? Maybe you can send us the application under test too, so we can reproduce this issue.
I can provide you with code sections from my VS2010 solution if you want. But I'm not sure you want me to send you the whole thing as it is more than necessary. My AUT is a major client/server application, so I cannot send you that. However,It might also be possible to allow you to remote into my environment using WebEx (I'll have to look into that... I think I have an account with them).
But you added this attribute to your code?
No, I did not. But I went and did that now, and it still makes no difference.

Do I send my code to [email protected]?

Aracknid

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

Re: ColumnIndex of Cell always 0 in Silverlight

Post by Support Team » Fri May 27, 2011 10:44 am

Hi,

Yes, please send your code to [email protected]

Thanks in advance.

Regards,
Peter
Ranorex Team
.
Image

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

Re: ColumnIndex of Cell always 0 in Silverlight

Post by Support Team » Tue May 31, 2011 1:47 pm

Support Team wrote:No, this setting only disables expensive attributes to show up in Ranorex tools (Spy, Recorder). They are evaluated anyway when executing Ranorex code.
At least that's the intended behavior of this setting. I just found out that it does not always work that way, i.e. expensive attributes might also be disabled at runtime when the "Disable expensive attributes in tools" setting is checked.

We will fix that problem with the next service release. Meanwhile, please uncheck the "Disable expensive attributes in tools" setting in the General Settings -> Advanced.

Regards,
Alex
Ranorex Team
.
Image

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: ColumnIndex of Cell always 0 in Silverlight

Post by Aracknid » Tue May 31, 2011 4:31 pm

OK, thanks for looking into it.

Aracknid