Page 1 of 1

wait a element until invisible

Posted: Wed Nov 27, 2019 7:51 am
by Thet Thet
Hi,

I want to wait the repository element until invisible from usercode.
I create a repository element from usercode
[ String alertBox = "/form/titlebar[@text='Downloading' and @accessiblerole='TitleBar']";]
and then I don't know how to wait that the repository element until does not exists.
Please help me.

Re: wait a element until invisible

Posted: Wed Nov 27, 2019 8:03 am
by odklizec
Hi,

At first, please edit the xpath in repo like this:

Code: Select all

/form/titlebar[@text='Downloading' and @accessiblerole='TitleBar' and @visible='True']
Then this method (used as UserCode action in recording) should do what you want:

Code: Select all

public void WaitForElementNotExists(RepoItemInfo repoInfoElement)
{
    repoInfoElement.WaitForNotExists(30000); 
}	
Where repoInfoElement should be connected to the repository element in question.

If you want to use Code module, then the code should look like this:

Code: Select all

repo.ElementNameInfo.WaitForNotExists(30000); 
You can replace 30000ms with whatever duration you like.

Re: wait a element until invisible

Posted: Wed Nov 27, 2019 8:43 am
by Thet Thet
Hi odklizec ,

Thanks you for your help.
But I don't know how to use Code module.

Code: Select all

repo.ElementNameInfo.WaitForNotExists(30000);
This is My User code,

Code: Select all

String alertBox = "/form/titlebar[@text='ファイルのダウンロード' and @accessiblerole='TitleBar' and @visible ='True']";
Validate.NotExists(alertBox,30000);
According to my user code, validate function is finished after 30000ms. But I want to wait until the element does not exist.

Re: wait a element until invisible

Posted: Wed Nov 27, 2019 9:05 am
by odklizec
Hi,

You can't use Validate then. Just create a repository element with given xpath...

Code: Select all

/form/titlebar[@text='ファイルのダウンロード' and @accessiblerole='TitleBar' and @visible ='True'
And then use the code I advised:

Code: Select all

// you must instantiate the repository in code module (this is done automatically in recording modules)
private static SolutionName.SolutionNameRepository repo = SolutionName.SolutionNameRepository.Instance;
...
//then you can call repository item like this...
repo.ElementNameInfo.WaitForNotExists();
WaitForNotExists is a RepoItemInfo method and it does not accept xpath. So you must create repository element if you want to use this method.

Another possibility would be using Exists() method, in some kind of custom loop. But this would require somewhat more coding. And if you are not skilled in coding, using repository and WaitForNotExists is the best approach. BTW, you can do the same much more easily with recording. You don't have to use code module for this specific task.

Re: wait a element until invisible

Posted: Wed Nov 27, 2019 10:24 am
by Thet Thet
Hi,

I know Validate method is wrong. I also want to use WaitForNotExists in the code. But I don't know well how can I do this.
What is ElementNameInfo?

Code: Select all

repo.ElementNameInfo.WaitForNotExists();

Re: wait a element until invisible

Posted: Wed Nov 27, 2019 10:38 am
by odklizec
Hi,

ElementNameInfo is just a name placeholder, which needs to be replaced with name (complete path) to your RepoItemInfo element, stored in repository. RepoItemInfo is a special Ranorex repository object, for accessing repo elements without risking "element not found" exception. You must replace ElementName, with the name of repository element. Basically, if you type repo., Ranorex should offer you a list of available repo elements, in which you need to find the titlebar element, you want to wait for (its not-existence). But this would happen only if you have repository instantiated in the code module of your choice (as I suggested in my previous post). The code should look like this:
RepoItemInfo.png