Element isn't found each time

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
WajdaW
Posts: 75
Joined: Wed Jan 05, 2011 6:45 pm

Element isn't found each time

Post by WajdaW » Sun Mar 13, 2011 4:33 pm

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

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Element isn't found each time

Post by Ciege » Mon Mar 14, 2011 4:58 pm

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?
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

WajdaW
Posts: 75
Joined: Wed Jan 05, 2011 6:45 pm

Re: Element isn't found each time

Post by WajdaW » Mon Mar 14, 2011 5:10 pm

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.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Element isn't found each time

Post by Ciege » Mon Mar 14, 2011 7:37 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

WajdaW
Posts: 75
Joined: Wed Jan 05, 2011 6:45 pm

Re: Element isn't found each time

Post by WajdaW » Mon Mar 14, 2011 7:48 pm

On what do you mean when you say AUT?
Last edited by WajdaW on Mon Mar 14, 2011 7:51 pm, edited 2 times in total.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Element isn't found each time

Post by Ciege » Mon Mar 14, 2011 7:50 pm

Application Under Test.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

WajdaW
Posts: 75
Joined: Wed Jan 05, 2011 6:45 pm

Re: Element isn't found each time

Post by WajdaW » Mon Mar 14, 2011 7:52 pm

Shouldn't timeout of 10 minutes take care of this?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Element isn't found each time

Post by Support Team » Mon Mar 14, 2011 7:54 pm

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
.
Image

WajdaW
Posts: 75
Joined: Wed Jan 05, 2011 6:45 pm

Re: Element isn't found each time

Post by WajdaW » Mon Mar 14, 2011 8:30 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Element isn't found each time

Post by Support Team » Tue Mar 15, 2011 1:25 pm

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
.
Image

WajdaW
Posts: 75
Joined: Wed Jan 05, 2011 6:45 pm

Re: Element isn't found each time

Post by WajdaW » Tue Mar 15, 2011 2:10 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Element isn't found each time

Post by Support Team » Tue Mar 15, 2011 5:43 pm

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
.
Image

WajdaW
Posts: 75
Joined: Wed Jan 05, 2011 6:45 pm

Re: Element isn't found each time

Post by WajdaW » Tue Mar 15, 2011 6:35 pm

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