Page 1 of 1

User code IF statement on a text field existence

Posted: Fri Oct 09, 2020 1:47 pm
by travisSAEG
I am creating user code in Ranorex for an IF statement that revolves around whether or not a text count field is there or not. The xpath to the field (repo element name is dayCount) that spy has right now is: ?/?/text[@name='60']

So I am going to use pseudocode here to denote what I want and what problem I am seeing.

IF (repo.dayCount.Exists())
{
move slider bar
} else {
report message
}

When I try using Exists I get an error during the build that says "Text does not contain a definition for Exists......."

What should I use to test for the existence of this element or what am I missing? I am very new to Ranorex.
I am using Ranorex 9.1.0
I am testing a desktop app in windows 10
I am using C#.

Re: User code IF statement on a text field existence

Posted: Sun Oct 11, 2020 10:38 pm
by odklizec
Hi,

You should use RepoItemInfo element, instead of Adapter element, like this...

Code: Select all

repo.dayCountInfo.Exists()
Ideally, pass the repo element to code via RepoItemInfo method parameter...

Code: Select all

YourMethod(RepoItemInfo nameOfElement)
{
IF (nameOfElement.Exists())
    { 
        move slider bar
...
}

Re: User code IF statement on a text field existence

Posted: Mon Oct 12, 2020 1:13 pm
by travisSAEG
Thank you for the response. I found and implemented the same solution late in the day on Friday. Your response just confirms I was on the right path.