Page 1 of 1

Element isn't found each time

Posted: Sun Mar 13, 2011 4:33 pm
by WajdaW
I have some login username field which I locate in each test at the beginning. For some reason sometimes this text field cannot be found. For example, I run 100 tests and in 4-5 of them this element cannot be found. I turned of ranorex cache.

Do you know what could be a problem?

Regards,

Vajda Vladimir

Re: Element isn't found each time

Posted: Mon Mar 14, 2011 4:58 pm
by Ciege
Please share your block of code that searches for the element.

It sounds like a timing issue. Have you checked the readystate of your AUT before you start searching for the element?

Have you increased the time that Ranorex is allotted to continue searching for an element?

Re: Element isn't found each time

Posted: Mon Mar 14, 2011 5:10 pm
by WajdaW
This is code which searches for element.



Since this is some excel add in, i start excel and right after that start searching for element. Like this:

Code: Select all

App = new Process();
App.StartInfo.FileName = application;
App.Start();
reportFactoryAddInGuiElements.LoginPane.LoginUserField.Click();

This actually call this property from repository file.

get
{
     return _loginuserfieldInfo.CreateAdapter<Ranorex.Container>(true);
}

My time out is set to 10 minutes, and excel starts in maximum 10-15 seconds so I think it should find this element.

Re: Element isn't found each time

Posted: Mon Mar 14, 2011 7:37 pm
by Ciege
You may want to add a check after your App.Start to wait for the AUT to fully load and be ready for interaction before you do a search for your element to click.

Re: Element isn't found each time

Posted: Mon Mar 14, 2011 7:48 pm
by WajdaW
On what do you mean when you say AUT?

Re: Element isn't found each time

Posted: Mon Mar 14, 2011 7:50 pm
by Ciege
Application Under Test.

Re: Element isn't found each time

Posted: Mon Mar 14, 2011 7:52 pm
by WajdaW
Shouldn't timeout of 10 minutes take care of this?

Re: Element isn't found each time

Posted: Mon Mar 14, 2011 7:54 pm
by Support Team
What's the exception message and stacktrace you get?
What's the RanoreXPath to the element that fails?
Which version of Ranorex do you use?
WajdaW wrote:Shouldn't timeout of 10 minutes take care of this?
Yes, unless: Have you ensured that the repository folder paths are all unique? E.g. if the RanoreXPath of the repository folder returns the Excel splash screen, then the item will not be found, since Ranorex tries to search inside the splash screen. That's just an example, but splash screens and pop ups always come to my mind when there is an "occasional" problem. :D

Regards,
Alex
Ranorex Team

Re: Element isn't found each time

Posted: Mon Mar 14, 2011 8:30 pm
by WajdaW
Here is stack trace:

Code: Select all

<![CDATA[Ranorex.ElementNotFoundException : Failed to find item 'Excel2007Repository.Microsoft_Excel.RF_Pane_Login.LoginUserField' within the specified timeout of 30m.
  ----> Ranorex.ElementNotFoundException : No element found for path 'form[@processname='EXCEL']/element/form/element[@controlname='ExcelTaskPaneHost']/container/element/element/text[@automationid='UserNameTextBox']/container[@automationid='PART_ContentHost']' within 30m.]]></message>
                          <stack-trace><![CDATA[at Ranorex.Core.Repository.RepoItemInfo.Find[T](Boolean findSingle, Boolean throwException)
at Ranorex.Core.Repository.RepoItemInfo.CreateAdapter[T](Boolean throwException)
at ABZ.OfficeAddInTestLogic.Excel2007RepositoryFolders.RF_Pane_LoginFolder.get_LoginUserField()
at ABZ.OfficeAddInTestLogic.LoginPaneExcel2007.get_LoginUserField()
at ABZ.OfficeAddInTestLogic.ReportFactoryOfficeAddInDriver.Login(String user, String password)
at ABZ.ExcelTest.ExcelStepDefinition.GivenIAmLoggedAsXWithX(String userName, String password)
at lambda_method(ExecutionScope , String , String )
at TechTalk.SpecFlow.Bindings.MethodBinding.InvokeAction(Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
at TechTalk.SpecFlow.TestRunner.ExecuteStepMatch(BindingMatch match, Object[] arguments)
at TechTalk.SpecFlow.TestRunner.ExecuteStep(StepArgs stepArgs)
at TechTalk.SpecFlow.TestRunner.CollectScenarioErrors()
at ABZ.ExcelTest.RoundingFactsInExcelDocumentFeature.RoundingUpAnItem(String cell, String column, String label, String times, String times2, String cellValue)
--ElementNotFoundException
I was using ranorex 2.3.5 and had this problem, now I have passed to 3.0 and this problem is still here.

RxPath is:

Code: Select all

/form[@processname='EXCEL']/element/form/element[@controlname='ExcelTaskPaneHost']/container/element/element/text[@automationid='UserNameTextBox']/container[@automationid='PART_ContentHost']
Sorry, but I'm little bad with English, what do you mean by Excel splash screen?
A screen with nothing on it?

Also, one offtopic question. I have 3 level hierarchy to this element, and each one there (rooted folders and element) have timeout of 10 minutes. And because of that my time out is 30 minutes. How to specify timeout to be 10 minutes for this element, but 10 as well for rooted folders. I don't want to this crashes after 30 minutes, but after 10. How to set those timeouts.

EDIT: About uniqueness of repository items:
I have ensured that only one excel process is running. I think that elements in repository are unique, but not 100% sure. If they are no unique shouldn't this heappen more than 4 times in 100?

Regards,

Vajda

Re: Element isn't found each time

Posted: Tue Mar 15, 2011 1:25 pm
by Support Team
Hi,
WajdaW wrote:Sorry, but I'm little bad with English, what do you mean by Excel splash screen?
A screen with nothing on it?
A splash screen is an image that appears while a game or program is loading.
Splash screens are typically used by especially large applications to notify the user that the program is in the process of loading. In other words, they provide feedback that a sometimes lengthy process is under way. A splash screen disappears when the application's main window appears.
WajdaW wrote:Also, one offtopic question. I have 3 level hierarchy to this element, and each one there (rooted folders and element) have timeout of 10 minutes. And because of that my time out is 30 minutes. How to specify timeout to be 10 minutes for this element, but 10 as well for rooted folders. I don't want to this crashes after 30 minutes, but after 10. How to set those timeouts.
Please take a look at this docu http://www.ranorex.com/support/user-gui ... eouts.html
WajdaW wrote:I have ensured that only one excel process is running. I think that elements in repository are unique, but not 100% sure. If they are no unique shouldn't this happen more than 4 times in 100?
Get you any warning in your Report, that your RxPath is not unique and therefore the absolute RxPath is used to search for the item?
Please also try to disable the caching for folders in your repository. How to disable caching
Have you also tried to copy the RxPath to Spy and have you checked if this RxPath is correct in this part of your automation?

Regards,
Peter
Ranorex Team

Re: Element isn't found each time

Posted: Tue Mar 15, 2011 2:10 pm
by WajdaW
Ah, that is splash screen. :)

I'll look for this timeouts.

I have disabled catching at beginning, so caching is off.

I copied RxPath to spy and only one element have been found, and it's that one which I need, so there is no problem with RxPath.

I added Ranorex.Delay(10000) after my app start.
And added to search for this element 3 times, and after this 3 times if doesn't find it that throws exception like this:

Code: Select all

int searchCount = 0;
            bool found = false;
            while (!found && searchCount < 3)
            {
                try
                {
                    reportFactoryAddInGuiElements.LoginPane.LoginUserField.Click();
                    found = true;
                }
                catch (Exception e) 
                {
                    if (searchCount < 3) searchCount++;
                    else throw e;
                }
            }
Now it works fine.
So what coused this problem? Splash screen?
Is there a better way to do this?
Some ranorex method to work around splash screen?

regards,

Vajda

Re: Element isn't found each time

Posted: Tue Mar 15, 2011 5:43 pm
by Support Team
Hi,
WajdaW wrote:So what coused this problem? Splash screen?
As alex wrote in the posting above:
Support Team wrote:E.g. if the RanoreXPath of the repository folder returns the Excel splash screen, then the item will not be found, since Ranorex tries to search inside the splash screen.
To overcome such an issue you have to add different attributes to your Splash screen element than to your application. Then such a problem shouldn't occur anymore.

Regards,
Peter
Ranorex Team

Re: Element isn't found each time

Posted: Tue Mar 15, 2011 6:35 pm
by WajdaW
Support Team wrote: To overcome such an issue you have to add different attributes to your Splash screen element than to your application. Then such a problem shouldn't occur anymore.
Of course. :)

I'll try this.

Regards,

Vajda