Experts I am trying to identify object through my c# script but it is giving me 'ElementNotFoundException', the same object I can identify using spy. I am using Ranorex3.0.4. The same script was working on earlier version. I am stuck due to this, any suggestion what could be the problem.
Following is the RanorexXPath "TAB = ".//a[@innertext='SomeTextHere']";"
Rocky
ElementNotFoundException
- artur_gadomski
- Posts: 207
- Joined: Mon Jul 19, 2010 6:55 am
- Location: Copenhagen, Denmark
- Contact:
Re: ElementNotFoundException
Shooting in the dark: timeout? How long does the code have to find this object?
Re: ElementNotFoundException
Thanks for your reply...
I have not set any timeout, its's Default timeout. How to set and how much timeout should i give.
ex
Ranorex.Core.Element admin1 = (Ranorex.Core.Element)mainPage.FindSingle(".//a[@innertext='SomeTextHere']");
admin1.Focus();
I have not set any timeout, its's Default timeout. How to set and how much timeout should i give.
ex
Ranorex.Core.Element admin1 = (Ranorex.Core.Element)mainPage.FindSingle(".//a[@innertext='SomeTextHere']");
admin1.Focus();
- artur_gadomski
- Posts: 207
- Joined: Mon Jul 19, 2010 6:55 am
- Location: Copenhagen, Denmark
- Contact:
Re: ElementNotFoundException
Find methods come in a version with a timeout duration. In your case it would be something like:
Try with different timeouts.I would guess if it doesn't find it in 5 minutes there is something wrong. Then save youself some time and make a shapshot of your application:
http://www.ranorex.com/forum/please-rea ... -t871.html
Ranorex.Core.Element admin1 = (Ranorex.Core.Element)mainPage.FindSingle(".//a[@innertext='SomeTextHere']", new Duration( 1 * 60 * 1000); admin1.Focus();for 1 minute timeout. (1 stands for minutes, 60 for seconds, and 1000 is just 1 second in miliseconds).
Try with different timeouts.I would guess if it doesn't find it in 5 minutes there is something wrong. Then save youself some time and make a shapshot of your application:
http://www.ranorex.com/forum/please-rea ... -t871.html
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: ElementNotFoundException
Hi,
http://www.ranorex.com/support/user-gui ... eouts.html
If you use code, as in your case use following. you have to set the timeout in milliseconds.
http://www.ranorex.com/Documentation/Ra ... ngle_1.htm
Regards,
Peter
Ranorex Team
To set the timeout of the elements you can take a look to following link if you use a repositoryrkarhe wrote:I have not set any timeout, its's Default timeout. How to set and how much timeout should i give.
ex
Ranorex.Core.Element admin1 = (Ranorex.Core.Element)mainPage.FindSingle(".//a[@innertext='SomeTextHere']");
admin1.Focus();
http://www.ranorex.com/support/user-gui ... eouts.html
If you use code, as in your case use following. you have to set the timeout in milliseconds.
Ranorex.Core.Element admin1 = (Ranorex.Core.Element)mainPage.FindSingle(".//a[@innertext='SomeTextHere']", 60000); admin1.Focus();FindSingle() method:
http://www.ranorex.com/Documentation/Ra ... ngle_1.htm
Regards,
Peter
Ranorex Team
- artur_gadomski
- Posts: 207
- Joined: Mon Jul 19, 2010 6:55 am
- Location: Copenhagen, Denmark
- Contact:
Re: ElementNotFoundException
How nice, you can use numbers rather than Duration object. You learn new stuff everyday 

Re: ElementNotFoundException
Thanks for mail. Tried with different timeout but still same problem. I am sure there is nothing wrong with xPath I am using as the same was working earlier.artur_gadomski wrote:Find methods come in a version with a timeout duration. In your case it would be something like:Ranorex.Core.Element admin1 = (Ranorex.Core.Element)mainPage.FindSingle(".//a[@innertext='SomeTextHere']", new Duration( 1 * 60 * 1000); admin1.Focus();for 1 minute timeout. (1 stands for minutes, 60 for seconds, and 1000 is just 1 second in miliseconds).
Try with different timeouts.I would guess if it doesn't find it in 5 minutes there is something wrong. Then save youself some time and make a shapshot of your application:
http://www.ranorex.com/forum/please-rea ... -t871.html
Ranorex.Core.Element administratn = (Ranorex.Core.Element)ecmMainPage.FindSingle(".//a[@innertext='SomeTextHere']", new Duration( 5 * 60 * 1000));
administratn.Focus();
Cursor.Position = new Point(administratn.ScreenLocation.X, administratn.ScreenLocation.Y);
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: ElementNotFoundException
The RanoreXPath looks OK, that's why the only thing we could imagine being a problem is the timeout, since the path will go through all(!) elements on the "mainPage".rkarhe wrote: I am sure there is nothing wrong with xPath I am using as the same was working earlier.
What is the exact error message you get?
Are there any warnings in the Ranorex Log File?
On the same machine, does Ranorex Spy find the RanoreXPath?
Could you make a brand new project with Ranorex Studio and just try to search for that one RanoreXPath?
Regards,
Alex
Ranorex Team
Re: ElementNotFoundException
Please see my answers below.
Support Team wrote:The RanoreXPath looks OK, that's why the only thing we could imagine being a problem is the timeout, since the path will go through all(!) elements on the "mainPage".rkarhe wrote: I am sure there is nothing wrong with xPath I am using as the same was working earlier.
What is the exact error message you get?
>>>{"No element found for path './/a[@innertext='Administration']' within 6m."}
Are there any warnings in the Ranorex Log File?
>>>One warning says
"The apartment state of the current thread is not set to STA. Please make sure that all threads accessing Ranorex methods have their apartment state set to STA."
On the same machine, does Ranorex Spy find the RanoreXPath?
>>> Yes, on same machine Ranorex Spy find the RanoreXPath.
Could you make a brand new project with Ranorex Studio and just try to search for that one RanoreXPath?
>>> Done, same problem here.
Regards,
Alex
Ranorex Team
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: ElementNotFoundException
Hi,
Please take a look to following post
http://www.ranorex.com/forum/unable-to- ... -t973.html
I think you simply forgot to set the STAThread.
Regards,
Peter
Ranorex Team
Please take a look to following post
http://www.ranorex.com/forum/unable-to- ... -t973.html
I think you simply forgot to set the STAThread.
Regards,
Peter
Ranorex Team
Re: ElementNotFoundException
Thnks, I am running my tests through nunit, added STAThred at the start of method and this is working fine now. Thank you very much.Support Team wrote:Hi,
Please take a look to following post
http://www.ranorex.com/forum/unable-to- ... -t973.html
I think you simply forgot to set the STAThread.
Regards,
Peter
Ranorex Team