RepoItemInfo cache of AbsolutePath

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
martinO
Posts: 4
Joined: Tue Dec 14, 2010 3:51 pm

RepoItemInfo cache of AbsolutePath

Post by martinO » Tue Dec 14, 2010 4:01 pm

Hi there

I made a little method to detect a window of my application with windowtitle. (SelfInfo is of type RepoItemInfo)
First time I invoke this method it works as expected.
After that the AbsolutePath in SelfInfo is set to "/form[@automationid='MainView']" and when I invoke the method the second time, the absolute path is set to "/form[@automationid='MainView']/form[@automationid='MainView' and @windowtext~'^somepath']" and that's why the window could not be located.

What can I do? Disable the cache on this.MyForm.UseCache doesn't work...
And this.MyForm.SelfInfo.AbsolutePath is readonly and I cannot reset this

Thanks in advance


Martin

public void SelectSolutionManagerWindowByFileName(string openedFileName)
{
  this.MyForm.SelfInfo.Path = string.Format(
    "/form[@automationid='MainView' and @windowtext~'^{0}']",
    openedFileName);
}

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: RepoItemInfo cache of AbsolutePath

Post by Support Team » Tue Dec 14, 2010 7:07 pm

It looks like you change the path of the wrong repository item. I'm not 100% sure without seeing your repository, but could it be that "MyForm" has a parent folder? If so, try changing the path of the parent folder instead of changing the path of "MyForm". Changing the RepoItemInfo.Path property always changes the relative path of the item with, not its absolute path.

Regards,
Alex
Ranorex Team
.
Image

martinO
Posts: 4
Joined: Tue Dec 14, 2010 3:51 pm

Re: RepoItemInfo cache of AbsolutePath

Post by martinO » Wed Dec 15, 2010 8:42 am

Hi Alex

MyForm has no parent folder.
protected MyRepositoryFolders.MyAppFolder MyForm
{
    get { return MyRepositoryFolders.Instance.Form1; }
}
Is it possible just to detect the window by windowtitle? Now the error is "Ranorex.ElementNotFoundException : No element found for path '/form[@automationid='MainView']/form[@automationid='MainView' and @windowtext~'^someTitle']' within 30s."

How can I change the query just to detect with the windowtext? Something like that
public void SelectSolutionManagerWindowByFileName(string openedFileName)
{
  this.MyForm.SelfInfo.Path = string.Format(
    "/self[@windowtext~'^{0}']",
    openedFileName);
}
so I get the path '/form[@automationid='MainView']/with[@windowtext~'^someTitle']' or similar

Thanks

Martin

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: RepoItemInfo cache of AbsolutePath

Post by Support Team » Wed Dec 15, 2010 12:21 pm

Hi,

following code modification should work for you:

use
this.MyForm.BasePath = string.Format("/self[@windowtext~'^{0}']", openedFileName);
instead of
this.MyForm.SelfInfo.Path = string.Format("/self[@windowtext~'^{0}']", openedFileName);
You have to disable caching too, to ensure that the right path is taken.

Kind regards,
Tobias
Support Team
.
Image

martinO
Posts: 4
Joined: Tue Dec 14, 2010 3:51 pm

Re: RepoItemInfo cache of AbsolutePath

Post by martinO » Wed Dec 15, 2010 2:34 pm

Hi Tobias

Thanks a lot. It works (with a little change).

Working code:
public void SetUseCache(bool useCache)
{
    this.MyForm.UseCache = useCache;
}

public void SelectSolutionManagerWindowByFileName(string openedFileName)
{
    this.MyForm.BasePath = string.Format(
      "/form[@automationid='MainView' and @windowtext~'^{0}']",
      openedFileName);
}
I invoke SetUseCache(false); at the beginning of the test and SetUseCache(true); at the end of the test to enable caching for next tests.

Maybe this codefragment helps someone other in future.

Cheers