Refreshing repository in C# during execution

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Arnout
Posts: 10
Joined: Wed Feb 17, 2016 2:05 pm

Refreshing repository in C# during execution

Post by Arnout » Fri Jun 17, 2016 1:32 pm

Hi there.

I'm looking for a way to refresh the repository during test execution.

The reason is this:

I have a checkbox listed in the repository, which can never be found during execution. Once I abort execution and open the spy through the repository however, the element can be found and the 'highlight' option highlights the element without any problems.

The reason this checkbox cannot be found is that it's dynamically generated once a certain value is chosen from a listbox. It doesn't exist before the value from the listbox has been selected. I already tried a small delay or clicking on a random element on the page first to give it some time to detect the checkbox.

Start
[SUCCES] - Open page
[SUCCES] - Click dropdown
[SUCCES] - Choose value (either with invoke action or with a mouse 'click')
-- the checkbox is generated --
[FAIL] - Check Checkbox (either with invoke action or with a mouse 'click')
Abort test

Once aborted, if I choose to 'Run Selected Items' on the 'check checkbox' step that had failed during prior execution, it works. Because, in this case, the checkbox already exists (as it was generated during the first, failed execution):

Start
[SUCCES] - Check Checkbox (either with invoke action or with a mouse 'click')

The problem seems to be that Ranorex 'indexes' all the elements on the page once it opens, and fails to update its repository once this checkbox is dynamically generated.

What I'm looking for is the c# command to refresh the repository.

Thanks in advance, have a nice weekend,

Arnout

Windows 7
Ranorex 6.0 (most recent version)
Application I'm testing against: Oracle Forms 11

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Refreshing repository in C# during execution

Post by Support Team » Mon Jun 20, 2016 3:30 pm

Hi Arnout,

Usually, the UI element is searched at the same moment as it's accessed (for example, before the click action is executed). I assume that the issue is caused by the folder caching mechanism.

Please try disabling the option Use Cache for the corresponding parent element in the repository.
open_repository_properties.png
use_cache_false.png
Please let me know if this resolves the issue.

Sincerely,
Johannes
You do not have the required permissions to view the files attached to this post.

Arnout
Posts: 10
Joined: Wed Feb 17, 2016 2:05 pm

Re: Refreshing repository in C# during execution

Post by Arnout » Tue Jun 21, 2016 10:18 am

Hello Johannes,

Thanks for your reply, I've checked the properties of the parent folder and the caching seems to be switched off/false. It was so by default. Is there any way for me to check the debug build if it actually builds with this as true due to some kind of bug?

Best regards,

Arnout

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Refreshing repository in C# during execution

Post by Support Team » Thu Jun 23, 2016 3:05 pm

Hi Arnout,

If the property is set to false, the issue doesn't seem to be related to folder caching. I would suggest contacting us by email in order to schedule a short remote session ([email protected]).

Alternatively, you could try creating a Ranorex Snapshot of the AUT during runtime after the checkbox was generated and before the mouse click is performed. This could be done with the Report.Snapshot action. Consequently, you could check if the checkbox exists in general.
report_snapshot.png
Sincerely,
Johannes
You do not have the required permissions to view the files attached to this post.

tvu
Posts: 195
Joined: Tue Apr 07, 2015 10:47 pm

Re: Refreshing repository in C# during execution

Post by tvu » Fri Jun 24, 2016 11:23 pm

Hi Arnout,

I was faced with a similar situation. What I did was created a repository item that represented all available check boxes. I would create a list of adapters after the check box appeared. Then I looped through the list until the desired check box adapter was found.

Here's an example of the code I would use. It would be in a method that would return a Ranorex.Checkbox.

Code: Select all

List<Ranorex.Checkbox> myListOfCheckBox = allCheckBoxInfo.CreateAdapters<Ranorex.Checkbox>();

for (Ranorex.Checkbox oneCheckBox in myListOfCheckBox)
{
    if (oneCheckBox == "SOME TYPE OF VALIDATION)
        return oneCheckBox;
}
I would call this method after selecting an item on the listbox.

Hope that helps.

Arnout
Posts: 10
Joined: Wed Feb 17, 2016 2:05 pm

Re: Refreshing repository in C# during execution

Post by Arnout » Mon Jun 27, 2016 11:58 am

Hrm, the solution to this problem was to change the identification of the checkbox from attribute ID to Index. The ID seemed to change every time the checkbox is generated. Overlooking this is a beginner's mistake that I haven't made in a long time. I thought I double-checked this. :?

Well, thanks everybody for trying to help (and sorry for wasting your time).

Cheers,

Arnout