How to get container textvalue

Ranorex Spy, Recorder, and Studio.
Priyanshu
Posts: 20
Joined: Wed May 22, 2019 5:48 am

How to get container textvalue

Post by Priyanshu » Mon Oct 07, 2019 7:46 am

Hi Team,

I want to validate if the textbox value is greater than 1 then only perform some action.
Can you please help how to write the code?
I am trying below which is not working
if((masterWinRepo.DebiteringsManuelScreen.AntalOkEdit.Element.GetAttributeValueText("text"))>=1)
Attachments
Antal.zip
(297.15 KiB) Downloaded 1 time

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

Re: How to get container textvalue

Post by odklizec » Mon Oct 07, 2019 8:16 am

Hi,

What exactly is not working? Could you please post exact error message you are getting or somewhat more detailed description of the problem you are experiencing?

As for the condition you are using now, you can't compare string with number! And I guess this also the source of your issue? You must convert the string to integer if you want to perform such comparison.

This code should do what you want:

Code: Select all

if(Convert.ToInt32(masterWinRepo.DebiteringsManuelScreen.AntalOkEdit.Element.GetAttributeValueText("text"))>=1)
Additionally, I would suggest to avoid referencing repo elements directly in code and rather use them as method parameters, like this:

Code: Select all

public void validateDifferenceInReports(RepoItemInfo repoInfoElement)
{
    if(Convert.ToInt32(repoInfoElement.CreateAdapter<Ranorex.Unknown>(false).Element.GetAttributeValueText("text"))>=1)
	{
	
	}
}
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

Priyanshu
Posts: 20
Joined: Wed May 22, 2019 5:48 am

Re: How to get container textvalue

Post by Priyanshu » Mon Oct 07, 2019 10:22 am

Thanks !! It worked
Convert.ToInt32(repoInfoElement.CreateAdapter<Ranorex.Unknown>(false).Element.GetAttributeValueText("text"))>=1)