Closing application

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
SteveSM.com
Posts: 10
Joined: Tue Mar 15, 2016 11:32 am

Closing application

Post by SteveSM.com » Fri Mar 18, 2016 3:03 pm

Ranorex 5.4.5
Windows 7

Hi,

Im having a minor issue trying to get Ranorex to close Excel after I have finished validating the contents.

Ive got a simple recording to close Excel by hitting the close icon in the top right corner, however as part of the validation check, I extend the width of a column so when I click close, it asks me if I want to save.
Ive record myself hitting "No" but when I run the module, it takes the full 30 seconds of searching before it eventually closes.

I get a warning in the log that im not sure quite sure how to address,
Item 'Statement_Matching_comRepository.MicrosoftExcel6983D72C3E2A48F581B617C2941.ButtonNo' could be found using its absolute path, but not using its relative path from the cached element of parent folder 'Statement_Matching_comRepository.MicrosoftExcel6983D72C3E2A48F581B617C2941'. This can happen if either the item search timeout is too small or if items within a rooted folder do not share a common parent element. To fix this problem, first increase the item search timeout. If this does not help, create a separate rooted folder for this item or disable caching for the specified folder.
The attachment Repository.PNG shows the current hierarchy I have set.

Ive watched both videos about the Ranorex XPath and ive tried using Ranorex Spy. When I open Spy, the window for the "do you want to save your changes" prompt is shown as a separate element? (see screenshot Ranorex Spy.PNG)

My understanding from the videos is that I should be able to drag the Form 'Microsoft Office Excel' into the repository but when I do that it doesnt add it. It seems to update the screenshot of the form MicrosoftExcel698D72...etc (see attachment Repository 2.PNG).


Ive considered just using the KillProcess command to close the application because that works, but im also trying to learn more about Ranorex and the Paths, Repository etc.

If you need anymore information, please let me know.

Thanks again.
You do not have the required permissions to view the files attached to this post.

asdf
Posts: 174
Joined: Mon Mar 21, 2016 3:16 pm

Re: Closing application

Post by asdf » Mon Mar 21, 2016 3:19 pm

Hey Steve,
First of all, I would recommend using the “Close Application” action on the Excel form, instead of clicking the close button.
Concerning the error message, the element could not be found using its relative path. To overcome this problem you could try disabling the “Use Cache” option in the properties of the parent repository item.
I hope I could help you.
Regards

SteveSM.com
Posts: 10
Joined: Tue Mar 15, 2016 11:32 am

Re: Closing application

Post by SteveSM.com » Tue Mar 22, 2016 11:45 am

Hi asdf,

Disabling the caching for the parent item worked perfectly.

I tried using the close application option but it still opens the "do you want to save" prompt which was the part I was having trouble with.

Thanks again.

Steve

asdf
Posts: 174
Joined: Mon Mar 21, 2016 3:16 pm

Re: Closing application

Post by asdf » Tue Mar 22, 2016 4:47 pm

Hey Steve,
Nice to hear that the first problem is solved.
To fix the 2nd problem, you could easily record the required steps to interact the dialog, or you could use a Popupwatcher.
For examplere, create a new code-module and insert the following code:
public void PopUp()
{
    PopupWatcher PopUpSaveAs = new PopupWatcher();
    PopUpSaveAs.Watch("(RanoreXPath of the “Yes/No”-Button)",Close);
    PopUpSaveAs.Start();
}

public static void Close(Ranorex.Core.RxPath myPath, Ranorex.Core.Element myElement)
{
	myElement.As<Ranorex.Button>().Click();
}

Regards,
asdf