0

Problem: screenshots are being overwritten in each device's result html file

Scenario: I am running calabash-android to test a single mobile app running on multiple devices.

The SCREENSHOT_PATH environment variable is set as c:/AndroidApp/Results/deviceScreenshots/

This location will store all screenshots taken.

In a batch file an output format of html is specified and an output location of C:\AndroidApp\Results\device1\deviceId

For multiple devices we have a separate line per device, so device1, device2 etc.. etc..

When I finish the run and examine the screenshots for each device, I am seeing that screenshots are being overwritten and they are being taken from the environment variable location.

e.g: Environment variable folder has 10 screenshots

device 1 has taken 10 screen shots device 2 has taken 10 screen shots

device 2 contains the same 10 screen shots as device one, due to the environment variable folder's imagenames being screenshot1.png, screenshot2.png etc etc

I have specified an unique device folder for each device html result output, so we do have unique result files, however the screenshots are being overwritten as being taken from the Environment variable folder.

any ideas? thanks all.

Graeme

Graeme Phillips
  • 131
  • 1
  • 1
  • 10

2 Answers2

1

Reading you question again I can see that you do set the path, but you use the same path for both runs? In case that is what you do and how you want to do it. My second option is probably most suitable for you(add a prefix to screenshots depending on device).

When you execute the test you can set screenshot path

SCREENSHOT_PATH=/tmp/foo/ calabash-android run

Link to Github about it https://github.com/calabash/calabash-android

So you could place screenshots in different folders. Or you could add a prefix to the screenshots taken based on the device the test is run on. Like

screenshot({:prefix => "/tmp", :name=>"my.png"})

Link to Github https://github.com/calabash/calabash-android/blob/master/documentation/ruby_api.md

Lasse
  • 1,153
  • 1
  • 10
  • 21
  • hi Lasse, hanks heaps for the reply, I will try this today, and if it works for me let you know. all the best, Graeme – Graeme Phillips Mar 27 '15 at 08:37
  • hi Lasse, what you have suggested works perfectly for running one device, however I require a solution (if indeed one exists) that caters for multiple devices run at once. we test at minimum 5 devices at once. so the SCREEN_SHOT environment variable can be set up to point anywhere, as can the results like you have stated (thank you), the problem still exists that all devices are 'pulling' the screenshots from the environment variable location and overwritting each other in the html files.... I am not sure it;s possible to be honest to do it the way I want it to work? different approach ? – Graeme Phillips Mar 27 '15 at 14:43
  • Okay now I understand what you are experiencing. That is an interesting scenario. There is another old post that mentions running them from seperate root folders http://stackoverflow.com/questions/13613660/testing-multiple-android-devices-on-one-machine Have you tried that? Btw If it is possible I would like to see you report. I have been putting of doing something similar myself. – Lasse Mar 28 '15 at 09:16
  • I have a similar set up to @Lasse's second suggestion and it is working for me. I handle all of my own screenshots (i.e. supress all of calabash's built in ones) and put the full file path into the screenshot command. That way I can set a suitable output for screenshots from each device. – alannichols Mar 28 '15 at 09:18
  • hi Lasse, this solution produces the same result as I am experiencing, the problem is not running multiple devices, it is the result file output from each device obtaining its' screenshot from the pool of screen shots that are placed in the folder I have set the environment variable too. running from different root folders still pulls from the environment variable. Alan, I will attempt your suggestion with 5 devices running a load test script, hopefully we will get to the bottom of it. thanks guys, appreciate the responses. – Graeme Phillips Mar 30 '15 at 06:26
  • hi Lasse and Alan, I;ve posted a solution in the answers, each screenshot saved to the environment variable location now outputs with a dateTimeStamp so it's unique.thanks again. G – Graeme Phillips Mar 30 '15 at 18:44
0

we tried a different approach by appending the screenshot name with a timeDate stamp instead of using an incremental integer counter.

added the following line of code to the operations.rb file. (not the failureHelpers.rb) to store the date in a specific format to the t1 variable, and output that t1 variable to the prefix.

@@t1 = DateTime.now.strftime("%Y%m%dT%H%M%S%3N")
path = "#{prefix}#{name}_#{@@t1}.png" 

code snippet of operations.rb is now:

def screenshot(options={:prefix => nil, :name => nil})
prefix = options[:prefix] || ENV['SCREENSHOT_PATH'] || ""
name = options[:name]

if name.nil?
  name = "screenshot"
    else
      if File.extname(name).downcase == ".png"
        name = name.split(".png")[0]
      end
    end

    @@t1 = DateTime.now.strftime("%Y%m%dT%H%M%S%3N")
    path = "#{prefix}#{name}_#{@@t1}.png" 

hope this helps, its not the solution to the original problem, just a re-thought out solution to the problem..phew...

anyway, thank you all for contributing , interesting puzzle indeed.

and thanks to my fellow tester here at work, was his work really not mine.

Graeme Phillips
  • 131
  • 1
  • 1
  • 10