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
properties.PNG (60.87 KiB) Viewed 900 times
I tried with

string name = item.FlavorElement.Name;

but I can't access it that way
no_property.png
no_property.png (11.25 KiB) Viewed 900 times
Do you have any idea how to handle this?

Thanks.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
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: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

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
RanorexSpy_TextBlock.png (64.87 KiB) Viewed 867 times
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
.
Image

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