airtest.core.helper module

class G[源代码]

基类:object

Represent the globals variables

BASEDIR = []
LOGGER = <airtest.utils.logwraper.AirtestLogger object>
LOGGING = <Logger airtest.core.api (DEBUG)>
SCREEN = None
DEVICE = None
DEVICE_LIST = []
RECENT_CAPTURE = None
RECENT_CAPTURE_PATH = None
CUSTOM_DEVICES = {}
classmethod add_device(dev)[源代码]

Add device instance in G and set as current device.

实际案例

G.add_device(Android())

参数:dev – device to init
返回:None
classmethod register_custom_device(device_cls)[源代码]
set_logdir(dirpath)[源代码]

set log dir for logfile and screenshots.

参数:dirpath – directory to save logfile and screenshots

Returns:

log(arg, timestamp=None, desc='', snapshot=False)[源代码]

Insert user log, will be displayed in Html report.

参数:
  • arg – log message or Exception object
  • timestamp – the timestamp of the log, default is time.time()
  • desc – description of log, default is arg.class.__name__
  • snapshot – whether to take a screenshot, default is False
返回:

None

实际案例

>>> log("hello world", snapshot=True)
>>> log({"key": "value"}, timestamp=time.time(), desc="log dict")
>>> try:
        1/0
    except Exception as e:
        log(e)
logwrap(f)[源代码]
device_platform(device=None)[源代码]
using(path)[源代码]
import_device_cls(platform)[源代码]

lazy import device class

delay_after_operation()[源代码]