How to update RepoElements in Usercode

Ranorex Studio, Spy, Recorder, and Driver.
MarkusW
Posts: 3
Joined: Wed Apr 03, 2013 12:19 pm
Location: Germany - Bayern - Forchheim

How to update RepoElements in Usercode

Post by MarkusW » Wed Mar 19, 2014 2:41 pm

Hi,

i'm facing a problem that i store some repoItems (RadioButtons etc.) in a Tuple set, that will provide some configuration that i have to perform on the UI.

Code: Select all

Tuple<RadioButton, RadioButton, RadioButton>[] configuration =
{
  //Configurations
  new Tuple<RadioButton, RadioButton, RadioButton>( ..repoItem.RadioButton1, repoItem.RadioButton2, repoItem.RadioButton3 ),  
...
}

RepoPath of the RadioButtons are like:
../element[@automationid='xyz' and @visible='True']/radiobutton[@automationid='xyz']
and then i do some checks and further steps....

Code: Select all

TestCode:

for( int i = 0; i < topoLabelSet.Length; i++ )
{
...
  Mouse.Click(configuration[ i ].Item1.Element);
  Mouse.Click(configuration[ i ].Item2.Element);
  Mouse.Click(configuration[ i ].Item3.Element);
...
}
Within a for-loop i iterate through the array of tuple to get and set the new 'configuration' of radiobuttons and then check some other stuff.

No i'm facing the problem, that in the created Tuple-Array the e.g. repoItem.RadioButton1 still points to an element/location that was valid at the time the TupleArray was created.
But in my next for-loop-iteration the position/location of the RadioButton1 has changed and this changed wasn't recognized and if i click on the RadioButton1 still the position of the first RadioButton1 is stored.
And exactly the visibility check of the XPath of the RadioButton
../element[@automationid='xyz' and @visible='True']/radiobutton[@automationid='xyz']
should lead to an other valid RadioButton1.

So my problem is, that the Element that was stored in the Tuple-Array needs to be updated but i can not find or just don't know how to update the Repo Element.

Any suggestions?

kind regards,
Markus

mzperix
Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Re: How to update RepoElements in Usercode

Post by mzperix » Tue Apr 01, 2014 10:11 am

Try to disable the caching mechanism for elements. Make note, that you can disable the caching of folders, not elements, so the proper way to do is:
- look for the buttons in repository
- look for the parent folder(s)
- hit F4 to see properties panel, and set use cahce to false, seen in here http://www.ranorex.com/forum/intermitte ... tml#p21009

Some side onte on how it works (the Support Tema answer has the info): http://www.ranorex.com/forum/enabled-ca ... html#p5537

MarkusW
Posts: 3
Joined: Wed Apr 03, 2013 12:19 pm
Location: Germany - Bayern - Forchheim

Re: How to update RepoElements in Usercode

Post by MarkusW » Wed Apr 09, 2014 6:48 am

Hi,

so i tested the feature with disabling the caching, but this didn't work either.

My solution anyway, that helped me got around the problem, is to switch over the possible RepoItems that are defined / used in the Tuple and then retrieved a new Element with the updated element location.

Code: Select all

for( int i = 0; i < configuration.Length; i++ )
{
  ...
  switch (configuration[i].Item1.ToString())
  {
    case "{RadioButton:RadioButton1}": ..repoItem.RadioButton1.Click();
      break;
    case "{RadioButton:RadioButton2}": ..repoItem.RadioButton2.Click();
      break;
    case "{RadioButton:RadioButton3}": ..repoItem.RadioButton3.Click();
      break;
    ....
  }
  ...
}
Its not the best solution, because if some new Items will be added to the Tuple, then you may not forget to extend the switch-case statement for this new items.

But it works for me.
If i'll find a better solution i will post it.

Markus