0

Even after a successful execution of my tests in DeviceFarm, I get an empty screenshots report. I have kept my code as simple as below -

from appium import webdriver
import time
import unittest

import os

class MyAndroidTest(unittest.TestCase):
    def setUp(self):
        caps = {}
        self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)
    def test1(self):
        self.driver.get('http://docs.aws.amazon.com/devicefarm/latest/developerguide/welcome.html')
        time.sleep(5)
        screenshot_folder = os.getenv('SCREENSHOT_PATH', '/tmp')
        self.driver.save_screenshot(screenshot_folder + 'screen1.png')
        time.sleep(5)

def tearDown(self):
        self.driver.quit()

if __name__ == '__main__':
        suite = unittest.TestLoader().loadTestsFromTestCase(MyAndroidTest)
        unittest.TextTestRunner(verbosity=2).run(suite)

I tested on a single device pool - AWS DeviceFarm run dashboard

Empty screenshots section

How can I make this work ?

TIA.

ZeroGraviti
  • 1,047
  • 2
  • 12
  • 28

2 Answers2

1

Missing a slash (/) before the filename (i.e., screen1.png). Line 15 should be as below -

self.driver.save_screenshot(screenshot_folder + '/screen1.png')
ZeroGraviti
  • 1,047
  • 2
  • 12
  • 28
0

Though I'm not sure exactly how to write this to a file in Device Farm here are the appium docs for the screenshot endpoint and a python example.

https://github.com/appium/appium/blob/master/docs/en/commands/session/screenshot.md

It gets a base 64 encoded string which then we would just need to save it somewhere like the appium screenshot dir the other answers mentioned. Otherwise we could also save it in the /tmp dir and then export it using the custom artifacts feature.

Let me know if that link helps.

James

jmp
  • 2,175
  • 2
  • 17
  • 16