Invert the logic for a Ranorex Validation sequence.

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
PMathis
Posts: 2
Joined: Tue Oct 23, 2012 7:22 pm

Invert the logic for a Ranorex Validation sequence.

Post by PMathis » Tue Dec 04, 2012 12:04 am

So here what i am trying to do. I am trying to get Ranorex to basically pass a segment of code if the passed in value is equal to anything but whats in the inner text field of an object. the segment of code is essentially what follows below:

Code: Select all

        	if (Condition=="Pass if Alarm Text is Present")
        	{
            Report.Log(ReportLevel.Info, "Validation", "Validating AttributeEqual (InnerText=$Message) on item 'Site.NewFolder.TheUnitIsExitingFenceBrandyn'.", repo.Site.NewFolder.TheUnitIsExitingFenceBrandynInfo);
            Validate.Attribute(repo.Site.NewFolder.TheUnitIsExitingFenceBrandynInfo, "InnerText", Message);
        	}
        	else
        	{
        	Report.Log(ReportLevel.Info, "Validation", "Validating AttributeEqual (InnerText=$Message) on item 'Site.NewFolder.TheUnitIsExitingFenceBrandyn', is not Present", repo.Site.NewFolder.TheUnitIsExitingFenceBrandynInfo);
			Validate.Attribute(repo.Site.NewFolder.TheUnitIsExitingFenceBrandynInfo, "InnerText", Message);
        	}
So i have a simple wrapper around some pre-made validation code. that determines if the text is equal to message passed in.

if they want the test to pass when the text is equal to anything but whats in the field they want to know that as well. a client is being picky about this, essentially they want to be very sure that the validation is working on multiple ends.

the simple questions is this, Can I invert the logic of a validation step simply?

I tried to play around with the Validate.notexists, however that sounded like it would only look to see if the element was not there, nothing to match against.

Any assistance would be appreciated.

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Invert the logic for a Ranorex Validation sequence.

Post by Ciege » Tue Dec 04, 2012 12:19 am

You could do this quite a bit more simply in user code...

Pseudo code to follow:

Code: Select all

if (myobject.innertext == myvar)
{
  report.fail("The text is equal");
}
else
{
  report.success("The text is different.");
}
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

PMathis
Posts: 2
Joined: Tue Oct 23, 2012 7:22 pm

Re: Invert the logic for a Ranorex Validation sequence.

Post by PMathis » Tue Dec 04, 2012 1:19 am

Quite helpful, I was defiantly over thinking the problem. This is a much more effective solution.

Thank you.