I'll do the best I can to explain what we're doing and how it's failing.
When interfacing with our UI, we use classes that represent a fairly generic type (such a "TextField" or "ComboBox" etc. that inherit from even more generic types (such as "Field").
These types get added to "Sections" (a collection of Fields), which get added to "Pages" (a collection of Sections).
We then have virtual methods that can be overridden to implement certain functionalities. This approach allows us to very quickly set up methods which can set and verify large amounts of fields very easily across different applications and so forth.
The problem is this - if we try to add the repository object to our class, we have to be on the page where the object exists to do so, if we're not, it says the object cannot be found. Conceptually, this did not make sense to us because we thought we were just adding the object repository reference, rather than the actual object itself.
However, it seems that when referring to the xPath in the repository, Ranorex is actually trying to use the object itself.
Now, if we are on the page when we try and add the objeects to our class, it's fine. However, if we navigate away from the page, and use the same object to verify some results later, the object again cannot be found - even though you can find it in the spy.
To me, it seems like the object is retrieved every time and some attributes are added "live", so when you try and refer to it later, it no longer matches (even though the xPath is the same and the object can be found with the Spy).
Here is a sample of what it looks like:
Code: Select all
switch (kvp.Key)
{
case WUCreditLimits.SPOTTRANSACTION:
this.fields.Add(new WUMoneyField(WUMPPApp.WUGetRepository().WUMppHome.Customer.PayablesSettings.CreditLimits.Limits.TextSpotLimit, kvp, moneyFormat));
break;
}
public WUMoneyField(Ranorex.InputTag textFieldObject, KeyValuePair<string, object> testField, string format) : base (textFieldObject, testField)
{
this.format = format;
}
/// <summary>
/// Sets the field value to the passed in the constructor.
/// </summary>
public override void SetWUField()
{
if (testField.Value == "*")
{
Random randomDecimal = new Random();
testField = new KeyValuePair<string, string>(testField.Key, randomDecimal.Next().ToString());
((Ranorex.InputTag)repObject).Value = testField.Value;
((Ranorex.InputTag)repObject).Click();
}
else
{
base.SetWUField();
}
}
One solution I was thinking of was to add the xPath of the object instead of the actual object, and then creating it in the set/verify methods. I'll see if that approach works...
But there's something I'm not understanding about how repository objects are managed during runtime that's preventing this from working as is now.
Any insights would be much appreciated!
Carson.