Validate.NotExists Overloads Problem

Ranorex Studio, Spy, Recorder, and Driver.
AccidentReport
Posts: 78
Joined: Tue Dec 04, 2012 2:30 pm

Validate.NotExists Overloads Problem

Post by AccidentReport » Mon Feb 03, 2014 1:41 pm

In order to confirm that an action has taken place on my webpage application I am trying to confirm that a button no longer exists. I originally recorded this and then converted it to UserCode:

Code: Select all

Validate.NotExists(repo.BTIA2.Form1.BtnCancel);
This code works as is but I can't use it directly as it returns a void. The content of the page requires a manual refresh for it to re-read the database and draw the required buttons. Sometimes this is quick but at times can take upto 30 seconds so I need to put this validation into a loop. Therefore I have chosen to use one of the overloads that returns a boolean. I have come up with this basic structure:

Code: Select all

while (btnNotExists == false) {
     //Check if button is still there
     btnNotExists = Validate.NotExists(repo.BTIA2.Form1.BtnCancel, 5000, "{0}", false);
}
The problem is that this is suddenly giving me the error:
Argument 1: cannot convert from 'Ranorex.InputTag' to 'string' (CS1503)
I can't see what the problem is given that the possible overloads for this method are:

Code: Select all

public static bool NotExists(RxPath path)
public static bool NotExists(RxPath path, Duration searchTimeout)
public static bool NotExists(RxPath path, Duration searchTimeout, string message)
public static bool NotExists(RxPath path, Duration searchTimeout, string message, Validate.Options options)
Does anyone have any suggestions as to why using the overloads of this method causes it to break!?

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Validate.NotExists Overloads Problem

Post by krstcs » Mon Feb 03, 2014 3:21 pm

You are attempting to pass in the actual repository button object instead of the path.

You will need to find the Path attribute for the element you are passing in and use that instead.
Shortcuts usually aren't...

AccidentReport
Posts: 78
Joined: Tue Dec 04, 2012 2:30 pm

Re: Validate.NotExists Overloads Problem

Post by AccidentReport » Mon Feb 03, 2014 4:56 pm

Like I said I just converted to code from the recorded action. The recorded action is:

Code: Select all

Validate.NotExists(repo.BTIA2.Form1.BtnCancel);
All I'm doing is adding the additional arguments. Why do I need to suddenly change the original repo item? I may just be being stupid here but I want to understand why...not just how to resolve it!

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Validate.NotExists Overloads Problem

Post by krstcs » Mon Feb 03, 2014 8:03 pm

Check out the Ranorex API at http://www.ranorex.com/Documentation/Ranorex/. Look at the Validate class under Ranorex. It lists all the member methods and their signatures. It will help with part of it.

The path is just one attribute of a repository object's instance. When you pass the repo object, .NET looks for the method that fits what you passed, and in this case doesn't find one. Some of this is basic object oriented coding, so I won't go too deep (although you should study some .NET and OOP when you have time).

In your case, there is no method call for Validate.NotExist that takes a RepoItemInfo object AND 3 other objects, so .NET can't find the method you are looking for.
Shortcuts usually aren't...

AccidentReport
Posts: 78
Joined: Tue Dec 04, 2012 2:30 pm

Re: Validate.NotExists Overloads Problem

Post by AccidentReport » Tue Feb 04, 2014 12:22 pm

OK, just to be apain then the basic converted code shouldn't work either since , as you are saying, it is using an object and not a string or rxpath as the method requires.

That aside what is the path of the object is repo.BTIA2.Form1.BtnCancel isn't!?

KurtZ
Posts: 12
Joined: Fri Jul 12, 2013 2:24 pm

Re: Validate.NotExists Overloads Problem

Post by KurtZ » Tue Feb 04, 2014 7:31 pm

See this link -- http://www.ranorex.com/Documentation/Ra ... Exists.htm

I'm just restating what krstcs has already said, just a little differently.

Your original snippet matches the method NotExists(Element). When you specify additional arguments, it is now trying to match NotExists(String, Duration, String, Boolean). In which case, the first argument has to be a string.

repo.BTIA2.Form1.BtnCancel is an element.
repo.BTIA2.Form1.BtnCancel.Element.GetPath() is the rxpath (a string) of your element

Your original snippet compiles because it matches a valid method. Your second snippet won't compile because the 1st argument's type is invalid for the method being matched.

AccidentReport
Posts: 78
Joined: Tue Dec 04, 2012 2:30 pm

Re: Validate.NotExists Overloads Problem

Post by AccidentReport » Wed Feb 05, 2014 3:21 pm

Oh right I understand now. I hadn't seen the additional overloads past the string and rxpath versions! Plus I thought the rxpath was the same as the repository path object.

Thanks!