Change report screenshot location

Mobile Testing, Android App Testing.
theraviz
Posts: 111
Joined: Sun Apr 14, 2019 9:46 am

Change report screenshot location

Post by theraviz » Fri Apr 01, 2022 12:11 pm

Hello,

For my mobile automation i need to save the screenshot alone. As mentioned in the below post,

1) is it possible to save the screenshot alone in a particular folder?

2) If not is it possible to customize the location of the report screenshot folder?

https://www.ranorex.info/taking-screens ... ml#p28263/

Jacob
Certified Professional
Certified Professional
Posts: 120
Joined: Mon Mar 22, 2021 10:01 pm

Re: Change report screenshot location

Post by Jacob » Fri Apr 01, 2022 8:08 pm

Hi theraviz,

It isn't currently possible to configure the folder in which image-based artefacts are stored in Ranorex Studio using the built-in Screenshot feature. It is possible to take a screenshot using Report.Screenshot() in a code module and then (also in code), move that image to another directory, but there is nothing built-in to Ranorex with this capability in mind at this time.

--Jacob
Image

theraviz
Posts: 111
Joined: Sun Apr 14, 2019 9:46 am

Re: Change report screenshot location

Post by theraviz » Sun Apr 03, 2022 6:19 pm

Thanks Jacob but would be helpful if anyone can provide a sample code for the same. Thanks in advance..

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Change report screenshot location

Post by odklizec » Mon Apr 04, 2022 7:28 am

Hi,

There is plenty of sample codes available in this forum. Check for example this post:
https://www.ranorex.info/viewtopic.php? ... 103#p34103
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

theraviz
Posts: 111
Joined: Sun Apr 14, 2019 9:46 am

Re: Change report screenshot location

Post by theraviz » Mon Apr 04, 2022 12:54 pm

Hi Pavel,

Thanks for your reply and sorry to bother you again. I tried the code provided in the post and some other codes in the forum too. But I could'nt find a way to pass RanorexRepository Item as element to capture.

When I pass the repository item as argument, it says "Cannot Convert from RepositoryItemInfo to Ranorex.Core.Element.

Kindly let me know how to pass a repository item as argument (Element) to the code below.

//Take a screenshot of a specific element
Bitmap image = Imaging.CaptureImageAuto(element.Element);

Thanks in advance

theraviz
Posts: 111
Joined: Sun Apr 14, 2019 9:46 am

Re: Change report screenshot location

Post by theraviz » Mon Apr 04, 2022 1:28 pm

I tried using Adapter instead of RepoItem and this time the previous error is gone but now I am getting "A generic error occured in GDI+"

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Change report screenshot location

Post by odklizec » Mon Apr 04, 2022 1:33 pm

Hi,

You must create or find an adapter of the repoiteminfo element passed to the method. Try something like this...

Code: Select all

        public void UserCodeMethod(RepoItemInfo repoElement)
        {
        	Bitmap image = Imaging.CaptureImageAuto(repoElement.CreateAdapter<Ranorex.Unknown>(false).Element);
        }
Ideally, replace 'Unknown' with appropriate element type. Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

theraviz
Posts: 111
Joined: Sun Apr 14, 2019 9:46 am

Re: Change report screenshot location

Post by theraviz » Mon Apr 04, 2022 1:58 pm

Hi Pavel,

Tried using adapters but it am getting 'A generic error occurred in GDI+ error.

This error is at the line where it tries to save the file. I could see the screenshot in the report but cant save the file due to this error.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Change report screenshot location

Post by odklizec » Mon Apr 04, 2022 2:17 pm

I'm afraid, I can't help you with that? For me it works. So it appears to be some kind of system-related issue? Please search the internet for this error and possible solutions.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

theraviz
Posts: 111
Joined: Sun Apr 14, 2019 9:46 am

Re: Change report screenshot location

Post by theraviz » Mon Apr 04, 2022 7:02 pm

Thanks Pavel for the supports