Ejemplo n.º 1
0
 def get_screenshots():
     for device in TestContext.STARTED_DEVICES:
         try:
             base_path = os.path.join(Settings.TEST_OUT_IMAGES,
                                      TestContext.CLASS_NAME,
                                      TestContext.TEST_NAME)
             png_path = os.path.join(base_path, device.name + '.png')
             File.delete(png_path)
             device.get_screen(png_path)
         except AssertionError:
             Log.warning('Failed to take screenshot of {0}'.format(
                 device.id))
 def is_available(avd_name):
     if Java.version() > 1.8:
         Log.warning('Can not check if {0} is available, because avdmanager is not compatible with java {1}.'
                     .format(avd_name, Java.version()))
         return True
     else:
         avd_manager = os.path.join(ANDROID_HOME, 'tools', 'bin', 'avdmanager')
         result = run(cmd='{0} list avd'.format(avd_manager))
         avds = result.output.splitlines()
         for avd in avds:
             if avd_name in avd:
                 return True
         return False
Ejemplo n.º 3
0
    def get_screenshots():
        # get host snapshot
        base_path = os.path.join(Settings.TEST_OUT_IMAGES, TestContext.CLASS_NAME, TestContext.TEST_NAME)
        try:
            import pyautogui
            png_path = os.path.join(base_path, 'host.png')
            File.delete(png_path)
            Folder.create(folder=os.path.dirname(png_path))
            pyautogui.screenshot().save(png_path)
            Log.info("Saved host os screen at {0}".format(png_path))
        except Exception:
            Log.warning('Failed to take screenshot of host os.')

        # get device screenshots
        for device in TestContext.STARTED_DEVICES:
            try:
                png_path = os.path.join(base_path, device.name + '.png')
                File.delete(png_path)
                device.get_screen(png_path)
            except AssertionError:
                Log.warning('Failed to take screenshot of {0}'.format(device.id))