wait a element until invisible

Ask general questions here.
Thet Thet
Posts: 27
Joined: Fri Jan 11, 2019 7:02 am

wait a element until invisible

Post by Thet Thet » Wed Nov 27, 2019 7:51 am

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.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6016
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: wait a element until invisible

Post by odklizec » Wed Nov 27, 2019 8:03 am

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Thet Thet
Posts: 27
Joined: Fri Jan 11, 2019 7:02 am

Re: wait a element until invisible

Post by Thet Thet » Wed Nov 27, 2019 8:43 am

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.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6016
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: wait a element until invisible

Post by odklizec » Wed Nov 27, 2019 9:05 am

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Thet Thet
Posts: 27
Joined: Fri Jan 11, 2019 7:02 am

Re: wait a element until invisible

Post by Thet Thet » Wed Nov 27, 2019 10:24 am

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();

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6016
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: wait a element until invisible

Post by odklizec » Wed Nov 27, 2019 10:38 am

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
RepoItemInfo.png (50.34 KiB) Viewed 191 times
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration