How to use screen_proxy method in Airtest

Best Python code snippet using Airtest Github


Full Screen

...112 """113 warnings.warn("No need to manually specify cap_method, airtest will automatically specify a suitable screenshot method, when airtest>=1.1.2")114 self.screen_proxy = name115 @property116 def screen_proxy(self):117 """118 Similar to touch_proxy, it returns a proxy that can automatically initialize an available screenshot method, such as Minicap119 Afterwards, you only need to call ``self.screen_proxy.get_frame()`` to get the screenshot120 类似touch_proxy,返回一个代理,能够自动初始化一个可用的屏幕截图方法,例如Minicap121 后续只需要调用 ``self.screen_proxy.get_frame()``即可获取到屏幕截图122 Returns: ScreenProxy(Minicap())123 Examples:124 >>> dev = Android()125 >>> img = dev.screen_proxy.get_frame_from_stream() # dev.minicap.get_frame_from_stream() is deprecated126 """127 if self._screen_proxy:128 return self._screen_proxy129 self._screen_proxy = ScreenProxy.auto_setup(self.adb, default_method=self._cap_method,130 rotation_watcher=self.rotation_watcher,131 display_id=self.display_id,132 ori_function=lambda: self.display_info)133 return self._screen_proxy134 @screen_proxy.setter135 def screen_proxy(self, cap_method):136 """137 Specify a screenshot method, if the method fails to initialize, try to use other methods instead138 指定一个截图方法,如果该方法初始化失败,则尝试使用其他方法代替139 Args:140 cap_method: "MINICAP" or :py:mod:`` object141 Returns:142 ScreenProxy object143 Raises:144 ScreenError when the connection fails145 Examples:146 >>> dev = Android()147 >>> dev.screen_proxy = "MINICAP"148 >>> from import Minicap149 >>> minicap = Minicap(dev.adb, rotation_watcher=dev.rotation_watcher)...

Full Screen

Full Screen Github


Full Screen

1"""2 Copyright © 2017 Bilal Elmoussaoui <>3 This file is part of Authenticator.4 Authenticator is free software: you can redistribute it and/or5 modify it under the terms of the GNU General Public License as published6 by the Free Software Foundation, either version 3 of the License, or7 (at your option) any later version.8 Authenticator is distributed in the hope that it will be useful,9 but WITHOUT ANY WARRANTY; without even the implied warranty of10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11 GNU General Public License for more details.12 You should have received a copy of the GNU General Public License13 along with Authenticator. If not, see <>.14"""15from os import path16from tempfile import NamedTemporaryFile17from gi.repository import Gio, GLib18class GNOMEScreenshot:19 """20 GNOME Screenshot interface implementation.21 Currently implements the only needed method by Authenticator.22 """23 interface = "org.gnome.Shell.Screenshot"24 path = "/org/gnome/Shell/Screenshot"25 def __init__(self):26 pass27 @staticmethod28 def area(filename: str = None) -> str:29 """30 Take a screen shot of an area and save it to a specific filename31 Using GNOME Shell Screenshot Interface.32 :param filename: output filename33 :type filename: str34 """35 if not filename:36 filename = path.join(GLib.get_user_cache_dir(),37 path.basename(NamedTemporaryFile().name))38 bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)39 screen_proxy = Gio.DBusProxy.new_sync(bus,40 Gio.DBusProxyFlags.NONE,41 None,42 GNOMEScreenshot.interface,43 GNOMEScreenshot.path,44 GNOMEScreenshot.interface,45 None)46 x, y, width, height = screen_proxy.call_sync('SelectArea', None, Gio.DBusCallFlags.NONE,47 -1, None).unpack()48 args = GLib.Variant('(iiiibs)', (x, y, width, height, False, filename49 )50 )51 screenshot = screen_proxy.call_sync('ScreenshotArea', args,52 Gio.DBusCallFlags.NONE, -1, None)53 success, filename = screenshot.unpack()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?