How to retrieve attribute value

Ask general questions here.
guptaravi2k
Posts: 6
Joined: Mon Jan 19, 2015 6:46 am

How to retrieve attribute value

Post by guptaravi2k » Thu Jan 22, 2015 2:52 am

Hi,

I am trying to retrieve value of InnetText from a repository element. (C#)

I have a repo element and its xpath looks is this:
/dom[@domain='10.31.160.99:6010']//div[#'ScrollPane#3']/div[2]/div/div[1]/div[4]/span[@innertext='22295505']

In UserCode file I want to retrieve value of innertext field and pass it on to a different function that perform further tests.

I am looking for API which does something like:
String value = Ranorex.GetAttribute(repo.ICMUAT.SpanTag22295505Info, "InnerText");

I am from java background so pls don't mind syntax.

Regards,
Ravi

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

Re: How to retrieve attribute value

Post by odklizec » Thu Jan 22, 2015 8:47 am

Hi,

The code you are looking for looks like this:

Code: Select all

string strValue = repo.ICMUAT.SpanTag22295505Info.GetAttributeValueText("InnerText");
BTW, if you are not sure how to create some code, you can always record an action or manually add an action to the recording table (see the list of available actions > here <) and then convert the selected action (or even multiple actions) into user code. Just right click the selected action(s) and from the appeared menu select "Convert to User Code". In this way you can quickly learn the code behind basic actions or even rapid prototyping things, even without a deep knowledge of coding ;)

Hope this helps?
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