How does FindSingle method works?

Best practices, code snippets for common functionality, examples, and guidelines.
RekhaG
Posts: 17
Joined: Fri Sep 22, 2017 12:47 am

How does FindSingle method works?

Post by RekhaG » Tue Oct 31, 2017 6:31 am

Hello,

i am trying to get a Container from the windows FORM using FindSingle method, but Ranorex is throwing an error message NoElement found for path

This is the Actual path for the container /form[@automationid='LoginWindow']/container[1]

Below is how i am trying to get it

public Form LoginForm
{
get
{
return DNA2UIMapsRepository.Instance.LoginWindow.Self;
}
}

public Container UserNameContainer
{
get
{
string rxPath = "/container[1]";
return LoginForm.FindSingle(rxPath,25);
}
}

Note: I have saved the LoginWindow Xpath in the repository and trying to do the find single using that path


Can someone help me here please?

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

Re: How does FindSingle method works?

Post by odklizec » Tue Oct 31, 2017 7:53 am

Hi,

Please post a Ranorex snapshot (not screenshot) of the problematic element. This would help us to analyze and better understand your problem and provide an adequate solution. Without (at very least) snapshot, we can only guess what's wrong. Thanks.
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

ahoisl
Certified Professional
Certified Professional
Posts: 192
Joined: Fri Sep 07, 2007 8:16 am

Re: How does FindSingle method works?

Post by ahoisl » Tue Oct 31, 2017 8:30 am

RekhaG wrote:string rxPath = "/container[1]";
You need to change this to a relative path by letting it start with "." -> "./container[1]".
However, that may not be the best path to use because of the index in there. It is usually better to search for some specific attribute value - if there are attributes to check :)

Additionally, a timeout of "25" milliseconds(!) is way to small. When you don't want to wait, just omit the timeout altogether, then Ranorex will just search once for the element.

Regards,
Alex
Ranorex Team

RekhaG
Posts: 17
Joined: Fri Sep 22, 2017 12:47 am

Re: How does FindSingle method works?

Post by RekhaG » Tue Oct 31, 2017 7:42 pm

Thanks ahoisl. It helped!