Hi all,
I am trying to check (in code level) if a form (from the repository) exists.
I tried to use : Validate.Exists(Xpath to form)
Since this function is void, I tried to catch the ValidationException but it's half solution since the Report shows a failure if this kind of exception is thrown.
I am sure there is a cleaner way to check if an item from the repository exists in run time.
Please help
Thanks,
Eli
Repository item existence check in run time
Re: Repository item existence check in run time
If you just want to check if it exists (and not VALIDATE it exists...) then try this:
or, if it is a repo folder...
The key is checking the SelfInfo object instead of the Self object.
Code: Select all
if (repo.MyObjectParent.MyObject.SelfInfo.Exists()) {
//do whatever you need to do here...
}
Code: Select all
if (repo.MyObjectParent.MyObjectInfo.Exists()) {
//do whatever you need to do here...
}
The key is checking the SelfInfo object instead of the Self object.
Shortcuts usually aren't...
Re: Repository item existence check in run time
Thanks!
I tried it but when the item does not exist the module is stuck.
Here is the code:
var repo = TestRepository.Instance;
var microTorrent331 = repo.MicroTorrent331;
if(microTorrent331.SelfInfo.Exists())
{
Report.Info(microTorrent331.SelfInfo.Exists().ToString());
}
When "microTorrent331.SelfInfo.Exists()" is false the execution is stuck.
Any ideas?
I tried it but when the item does not exist the module is stuck.
Here is the code:
var repo = TestRepository.Instance;
var microTorrent331 = repo.MicroTorrent331;
if(microTorrent331.SelfInfo.Exists())
{
Report.Info(microTorrent331.SelfInfo.Exists().ToString());
}
When "microTorrent331.SelfInfo.Exists()" is false the execution is stuck.
Any ideas?
Re: Repository item existence check in run time
How long did you wait?
It should only be stuck for the timeout length, which is typically 30s.
You could add a little more too it to manipulate the timeout, like:
That would set a temporary 1/2 second timeout, and then set it back.
EDIT: You may need to use the INFO object again to get and set the search timeout, it depends on your repo structure.
It should only be stuck for the timeout length, which is typically 30s.
You could add a little more too it to manipulate the timeout, like:
Code: Select all
var repo = TestRepository.Instance;
var microTorrent331 = repo.MicroTorrent331;
//Save the old duration...
Duration oldDur = microTorrent331.SearchTimeout;
//Set the new, temp duration...
microTorrent331.SearchTimeout = new Duration(500); //500 ms, 1/2 sec.
if(microTorrent331.SelfInfo.Exists())
{
Report.Info(microTorrent331.SelfInfo.Exists().ToString());
}
//Reset the original duration
microTorrent331.SearchTimeout = oldDur;
EDIT: You may need to use the INFO object again to get and set the search timeout, it depends on your repo structure.
Shortcuts usually aren't...
Re: Repository item existence check in run time
Cool
Thank you!
Thank you!