How to write an ObjectExists method
Posted: Fri Jan 13, 2012 5:31 pm
Hello,
I'm writing all of my automation in Visual Studio 2010, including the declaration of all my objects.
Because I don't have an "ObjectInfo" I can't use .exists. I want to write a method to do so. Currently, for each case I will write something like:
Instead of writing this out each time I want to see if an object exists, I'd like to write a method. But I'm not sure how to pass in a generic type of "object".
Essentially what I'm looking at is:
Is this possible? Or is there another way to go about this?
Thanks,
Jason
I'm writing all of my automation in Visual Studio 2010, including the declaration of all my objects.
Because I don't have an "ObjectInfo" I can't use .exists. I want to write a method to do so. Currently, for each case I will write something like:
Code: Select all
Ranorex.Button aButton;
var closedButtonExists = Host.Local.TryFindSingle("/form...", 2000, out aButton);
if (closedButtonExists)
{
aButton.Click();
}
Essentially what I'm looking at is:
Code: Select all
public bool ObjectExists(Ranorex.Object myObject, string myXpath)
{
Ranorex.myObject someObject;
var doIExist = ...
}
Thanks,
Jason