User Code IF Condition

Best practices, code snippets for common functionality, examples, and guidelines.
Posts: 7
Joined: Wed Nov 06, 2019 1:36 pm

User Code IF Condition

Post by oli129 » Tue Dec 10, 2019 3:06 pm

Hi everyone! May I ask for your help?

Given three text fields in a scrollable list with multiple rows, that are added as repository items: "ID", "METHOD" and "SUB".

I need to click on and select that ID (row), where the METHOD and the SUB equals a value that is provided in JIRA.

123 / N / H
123 / F / S

So, I need to select that row where the ID is '123' and the METHOD is 'F' and SUB is 'S'.

(There can be multiple METHOD and SUB types under a single ID.)

I am unable to provide a snapshot since it is forbidden for me.

I have tried to create a user code, however I am unsure, how to create multiple conditions:

Code: Select all

        public static void ScrollToElement(RepoItemInfo repoItemToFind, Adapter scrollTab, string screenText)
		Text foundElement=null;
		while (!repoItemToFind.Exists(200, out foundElement) && !screenText.AttributeEqual(100, out foundElement))
//		foundElement.EnsureVisible();
It won't build since the parameters are not bool type.

Could you please help me?
Thank you very much!

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

Re: User Code IF Condition

Post by odklizec » Tue Dec 10, 2019 3:26 pm


Sadly, this is exactly where the snapshot is required. Without snapshot, we can only guess how the element in question looks like. Generally speaking, you may not need to use user code at all! Usually, selection of an element, based of other elements, could be done just by creating a clever xpath, where ID, METHOD and SUB are used as variables. But as mentioned, without seeing the snapshot, it's impossible to tell how the xpath should look like.

If you cannot provide snapshot, you could either look at the screencasts available here (mainly Advanced RanoreXPath manipulation):
Eventually, contact Ranorex support and request remote session. 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

Posts: 7
Joined: Wed Nov 06, 2019 1:36 pm

Re: User Code IF Condition

Post by oli129 » Wed Dec 11, 2019 2:55 pm

Thank you very much Pavel!

Since my snapshot may contain sensitive information I am not allowed to post it publicly. I already tried to get in touch with the support team.