Page 1 of 1

User Code IF Condition

Posted: Tue Dec 10, 2019 3:06 pm
by oli129
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.

ID / METHOD / SUB
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

[UserCodeMethod]
        public static void ScrollToElement(RepoItemInfo repoItemToFind, Adapter scrollTab, string screenText)
	    {
        Mouse.MoveTo(scrollTab);
        Mouse.Click(scrollTab);
        
		Text foundElement=null;
		
		while (!repoItemToFind.Exists(200, out foundElement) && !screenText.AttributeEqual(100, out foundElement))
		{
            Mouse.ScrollWheel(-50);
		}
//		foundElement.EnsureVisible();
		foundElement.MoveTo();
		foundElement.Click();
	}
It won't build since the parameters are not bool type.

Could you please help me?
Thank you very much!

Re: User Code IF Condition

Posted: Tue Dec 10, 2019 3:26 pm
by odklizec
Hi,

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):
https://www.ranorex.com/resources/
Eventually, contact Ranorex support and request remote session. Hope this helps?

Re: User Code IF Condition

Posted: Wed Dec 11, 2019 2:55 pm
by oli129
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.