How to create an "Element" entry for making a screenshot of the desktop (entire window what the user is seeing)

Ask general questions here.
User avatar
_KK_
Posts: 36
Joined: Tue Nov 21, 2017 12:51 pm

How to create an "Element" entry for making a screenshot of the desktop (entire window what the user is seeing)

Post by _KK_ » Mon Jul 29, 2019 10:08 am

Hello Forum!

We created a PopUpWatch for OS exceptions like "… has stopped working".
In the callback we call the method "HandleAndCloseWatchedDialog" we want to execute when the event (the exception) occurs.

Code: Select all

myPopupWatcher.Watch(new RxPath("/form[@title='Basereport']/?/?/element[@instance='0']/button[@text='Close the program']"), HandleAndCloseWatchedDialog);
A helper class on our Project has a method with name TakeScreenshotOfElement(Element element, string errorText, string category).
It shall create a screenshot for further investigations.

How to "create" the "entire Desktop" as "Element" (what the user is seening when the method is called), adding it in the repo and having Access to without compile errors?

Thanks for your help.

Best regards

_KK_

User avatar
Vega
Posts: 161
Joined: Mon Jul 11, 2016 2:15 pm

Re: How to create an "Element" entry for making a screenshot of the desktop (entire window what the user is seeing)

Post by Vega » Tue Jul 30, 2019 8:19 pm

Give this a try and let me know if this is what you are looking for:

Code: Select all

Report.Screenshot(ReportLevel.Info, "User", "", "/", false);
within the parameters you will see "/" which is the target. "/" is the RanoreXPath I am using and that essentially returns everything. Tested and captured my whole desktop with multiple monitors.

Hope this helps

User avatar
_KK_
Posts: 36
Joined: Tue Nov 21, 2017 12:51 pm

Re: How to create an "Element" entry for making a screenshot of the desktop (entire window what the user is seeing)

Post by _KK_ » Thu Aug 01, 2019 8:44 am

Hi Vega!

Thanks for your Reply.

I guess your Approach doesnt fit the Need that this must be in "flavor" as "Element element".
Maybe you have read that the provided method "TakeScreenshotOfElement" taking a screenshot.
It has a first Parameter which must be satisfied as "Element".

I found myself a solution after I have included in the repo some entries and call now the following Code in the method which is called from the PopUpWatch when it finds the pattern:

Code: Select all

TestFailureHelpers.TakeScreenshotOfElement(Ranorex_Automation_HelpersRepository.Instance.Basereport_PopUpWatch_Exception.Fensterdialog_BasereportHasStoppedWorking.Element, "ssome useful Information to the user what happened", "warn");
			

Maybe the use of a PopUpWatch "creates" more issues during test than to acknowledge the undesired popup.
I found here in the Forum an answer that testexcecution and PopUpWatch is not "synchronized".
Testexecution is continued and Maybe the close-command by the watcher hits not the correct target.

Best regards

_KK_