Hello every one,
Is there an equivalent to RepoItemInfo class exist function in adapter class, what I want is to verify id an object exist in the SUT and then execute my action but using Adapter class, I tried to use both functions Valid and Visible and also use Validate class exist function wich take an adapter as parameter but all this functions lunch an exception if the element does not exist.
Thanks in advance for your replies.
repoItemInfo's exist function equivalent in adapter object
Re: repoItemInfo's exist function equivalent in adapter object
No.
The Adapter object does not have an Exists() method, only the RepoItemInfo instance for the given Adapter does. Is there a reason why you don't want to use the RepoItemInfo.Exist() method?
Another option may be to wrap your Validate.Exists() method with your own try-catch block so that the error is not thrown to the test runner. But this requires code, and if you want to do it multiple times it becomes quite cumbersome, although you could make it a method that does it given specific inputs.
The Adapter object does not have an Exists() method, only the RepoItemInfo instance for the given Adapter does. Is there a reason why you don't want to use the RepoItemInfo.Exist() method?
Another option may be to wrap your Validate.Exists() method with your own try-catch block so that the error is not thrown to the test runner. But this requires code, and if you want to do it multiple times it becomes quite cumbersome, although you could make it a method that does it given specific inputs.
Shortcuts usually aren't...
Re: repoItemInfo's exist function equivalent in adapter object
Thanks Krstcs for your reply, what I am trying to do is to create a custom function I call it ClickToDisappear :
Now I need an equivalent to this function thaiking as a parameter an Adapter, here is what I did :
is my code correct, does it do the same thing as the first function?
Code: Select all
public static void ClickToDisappear (RepoItemInfo BtnToClick, string coordinates)
{
CLICK_OBJECT_2:
{
BtnToClick.FindAdapter<Unknown>().MoveTo(coordinates);
CheckCursorStatus();
BtnToClick.FindAdapter<Unknown>().Click(coordinates, 200);
}
CheckCursorStatus();
if(BtnToClick.Exists(5000)){
goto CLICK_OBJECT_2;
}
Code: Select all
public static void ClickToDisappear (Adapter BtnToClick, string coordinates)
{
string xpath = item.GetPath().ToString();
CLICK_OBJECT_2:
{
BtnToClick.MoveTo(coordinates);
CheckCursorStatus();
BtnToClick.Click(coordinates, 200);
}
CheckCursorStatus();
Element em = null;
if(Host.Local.TryFindSingle(xpath, 5000, out em));
goto CLICK_OBJECT_2;
}
Re: repoItemInfo's exist function equivalent in adapter object
Hi,
I'm somewhat lost here I'm not quite sure what exactly is your problem with RepoItemInfo class and why you want to use Adapter class instead of RepoItemInfo?
In your initial post you mentioned, that if you pass an element using Adapter class and the passed element does not exists, method throws an exception. This is exactly why you should use RepoItemInfo class instead.
I would personally use code like this:
I'm somewhat lost here I'm not quite sure what exactly is your problem with RepoItemInfo class and why you want to use Adapter class instead of RepoItemInfo?
In your initial post you mentioned, that if you pass an element using Adapter class and the passed element does not exists, method throws an exception. This is exactly why you should use RepoItemInfo class instead.
I would personally use code like this:
Code: Select all
public static void ClickToDisappear (RepoItemInfo btnToClick, string coordinates)
{
CheckCursorStatus();
if(btnToClick.Exists(5000))
{
Ranorex.Unknown btnToClickAdapter = btnToClick.CreateAdapter<Unknown>(true);
btnToClickAdapter.MoveTo(coordinates);
CheckCursorStatus();
btnToClickAdapter.Click(coordinates, 200);
}
}
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
Re: repoItemInfo's exist function equivalent in adapter object
Hi odklizec,
Thanks for your reply, in my case I need to use an adapter instance in my custom function,
the goal from my function is the reclick again in case that an element did not disappear from the screen (Because in some cases the click effect in the first time do not work because of the environement is slow or whatever)
In case I was using RepoItemInfo it worked fine, but now and because we need to integrate Ranorex with an MBT solution I need to change function signature to use Adapter object.
Hope my problem was well explained .
Thanks for your reply, in my case I need to use an adapter instance in my custom function,
Code: Select all
public static void ClickToDisappear (Adapter ElementToClick, string coordinates)
In case I was using RepoItemInfo it worked fine, but now and because we need to integrate Ranorex with an MBT solution I need to change function signature to use Adapter object.
Hope my problem was well explained .
Re: repoItemInfo's exist function equivalent in adapter object
Hi,
I'm afraid, I still don't get it I still somehow don't understand, why it's so important for you to use Adapter class in custom method, instead of RepoItemInfo, which is clearly better solution?
Additionally, doing a workaround for potentially missed/not performed click is, in my opinion, not a very good idea. You should rather investigate the reason of failed clicks (either the AUT or test environment problem). You see, if your test randomly fails, it's not stable and therefore, not very usable in a long-term run, not to mention day-to-day usage.
I'm afraid, I still don't get it I still somehow don't understand, why it's so important for you to use Adapter class in custom method, instead of RepoItemInfo, which is clearly better solution?
Additionally, doing a workaround for potentially missed/not performed click is, in my opinion, not a very good idea. You should rather investigate the reason of failed clicks (either the AUT or test environment problem). You see, if your test randomly fails, it's not stable and therefore, not very usable in a long-term run, not to mention day-to-day usage.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
Re: repoItemInfo's exist function equivalent in adapter object
Hi
In the near future we will use an MBT solution that has an integration with Ranorex and a feature to edit scripts automaticaly on the MBT Side when we edit scripts on Ranorex side.
The problem is that the integration they have is based on adapter object, and testing the features of the MBT solution using RepoItemInfo Objects didn't work, so we need to change functions definitions to use Adapter instead of RepoItemInfo.
In the near future we will use an MBT solution that has an integration with Ranorex and a feature to edit scripts automaticaly on the MBT Side when we edit scripts on Ranorex side.
The problem is that the integration they have is based on adapter object, and testing the features of the MBT solution using RepoItemInfo Objects didn't work, so we need to change functions definitions to use Adapter instead of RepoItemInfo.
Re: repoItemInfo's exist function equivalent in adapter object
OK, I now understand. In this case, I would suggest to ask the author of integration to adapt it to work with RepoItemInfo as well. As mentioned, you will most experience exceptions caused by not existing elements, passed as Adapters. And the only reasonable solution is using RepoItemInfo class.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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