How to get FlavorElement.Name property?

Best practices, code snippets for common functionality, examples, and guidelines.
marasanov
Posts: 8
Joined: Thu Oct 30, 2014 2:40 pm

How to get FlavorElement.Name property?

Post by marasanov » Tue Sep 22, 2015 2:24 pm

Hi all,

I need to get FlavorElement,Name property (see snapshot below)
properties.PNG
I tried with

string name = item.FlavorElement.Name;

but I can't access it that way
no_property.png
Do you have any idea how to handle this?

Thanks.
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7469
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to get FlavorElement.Name property?

Post by odklizec » Tue Sep 22, 2015 2:33 pm

Hi,

Have you tried this...

Code: Select all

string name = item.FlavorName
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

marasanov
Posts: 8
Joined: Thu Oct 30, 2014 2:40 pm

Re: How to get FlavorElement.Name property?

Post by marasanov » Tue Sep 22, 2015 3:11 pm

Yes, I get 'WPF' when I try that.

I've managed to get a workaround with

Code: Select all

string name = item.ToString();    // this returns {Text:Engineer}

// and then I do search/replace
name = name.Replace("{Text:",string.Empty);
name = name.Replace("}",string.Empty);
This gets me what I need but it's not very elegant solution :)

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

Re: How to get FlavorElement.Name property?

Post by Support Team » Thu Sep 24, 2015 2:00 pm

Hello marasanov,

I would suggest taking a look at the corresponding element with Ranorex Spy.
RanorexSpy_TextBlock.png
In my sample, the value for the 'Name'-attribute of the TextBlock-element is 'Engineer'.
You can read this value using the GetAttributeValueText()-method for the corresponding element.

Code: Select all

string name = repo.<Form>.<TextBlock>.Element.GetAttributeValueText("Name");
Please let me know if you need more information.

Regards,
Johannes
You do not have the required permissions to view the files attached to this post.

Sundaytwins
Posts: 14
Joined: Thu Nov 02, 2017 2:55 pm

Re: How to get FlavorElement.Name property?

Post by Sundaytwins » Thu Nov 02, 2017 2:59 pm

HI,

I struggled just as you to get the 'Name' property from Flavorelement.

I got there using this:

Code: Select all

var CurText = ((Ranorex.Plugin.MsaaFlavorElement)cell.Element.FlavorElement).Name;
I think you could use a string also.

Hope this helps to get a more 'practical' solution to your problem.

Best regards,
Dominic