airtest.core.ios.ios module¶
-
decorator_retry_session
(func)[源代码]¶ When the operation fails due to session failure, try to re-acquire the session, retry at most 3 times
当因为session失效而操作失败时,尝试重新获取session,最多重试3次
-
decorator_retry_for_class
(cls)[源代码]¶ Add decorators to all methods in the class
为class里的所有method添加装饰器
decorator_retry_session
-
class
IOS
(addr='http://localhost:8100/')[源代码]¶ -
ios client
- before this you have to run WebDriverAgent
xcodebuild -project path/to/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination "id=$(idevice_id -l)" test
iproxy $port 8100 $udid
-
uuid
¶
-
is_pad
¶ Determine whether it is an ipad(or 6P/7P/8P), if it is, in the case of horizontal screen + desktop, the coordinates need to be switched to vertical screen coordinates to click correctly (WDA bug)
判断是否是ipad(或 6P/7P/8P),如果是,在横屏+桌面的情况下,坐标需要切换成竖屏坐标才能正确点击(WDA的bug) Returns:
-
device_info
¶ get the device info.
注解
Might not work on all devices
返回: dict for device info, eg. AttrDict({ ’timeZone’: ‘GMT+0800’, ‘currentLocale’: ‘zh_CN’, ‘model’: ‘iPhone’, ‘uuid’: ‘90CD6AB7-11C7-4E52-B2D3-61FA31D791EC’, ‘userInterfaceIdiom’: 0, ‘userInterfaceStyle’: ‘light’, ‘name’: ‘iPhone’, ‘isSimulator’: False})
-
orientation
¶ return device oritantation status in LANDSACPE POR
-
display_info
¶
-
touch_factor
¶
-
get_render_resolution
()[源代码]¶ Return render resolution after rotation
返回: offset_x, offset_y, offset_width and offset_height of the display
-
snapshot
(filename=None, strType=False, quality=10, max_size=None)[源代码]¶ take snapshot
参数: - filename – save screenshot to filename
- quality – The image quality, integer in range [1, 99]
- max_size – the maximum size of the picture, e.g 1200
返回: display the screenshot
-
touch
(pos, duration=0.01)[源代码]¶ 参数: - pos – coordinates (x, y), can be float(percent) or int
- duration (optional) – tap_hold duration
Returns: None
实际案例
>>> touch((100, 100)) >>> touch((0.5, 0.5), duration=1)
-
swipe
(fpos, tpos, duration=0, *args, **kwargs)[源代码]¶ 参数: - fpos – start point
- tpos – end point
- duration (float) – start coordinate press duration (seconds), default is 0
返回: None
实际案例
>>> swipe((1050, 1900), (150, 1900)) >>> swipe((0.2, 0.5), (0.8, 0.5))
-
keyevent
(keyname, **kwargs)[源代码]¶ Perform keyevent on the device
参数: - keyname – home/volumeUp/volumeDown
- **kwargs –
Returns:
-
text
(text, enter=True)[源代码]¶ Input text on the device :param text: text to input :param enter: True if you need to enter a newline at the end
返回: None 实际案例
>>> text("test") >>> text("中文")
-
install_app
(uri, package)[源代码]¶ curl -X POST $JSON_HEADER -d “{“desiredCapabilities”:{“bundleId”:”com.apple.mobilesafari”, “app”:”[host_path]/magicapp.app”}}” $DEVICE_URL/session https://github.com/facebook/WebDriverAgent/wiki/Queries
-
start_app
(package, *args)[源代码]¶ 参数: package – the app bundle id, e.g com.apple.mobilesafari
返回: None 实际案例
>>> start_app('com.apple.mobilesafari')
-
app_state
(package)[源代码]¶ 参数: package – 返回: - {
- “value”: 4, “sessionId”: “0363BDC5-4335-47ED-A54E-F7CCB65C6A65”
}
value 1(not running) 2(running in background) 3(running in foreground)? 4(running)
实际案例
>>> dev = device() >>> start_app('com.apple.mobilesafari') >>> print(dev.app_state('com.apple.mobilesafari')["value"]) # --> output is 4 >>> home() >>> print(dev.app_state('com.apple.mobilesafari')["value"]) # --> output is 3 >>> stop_app('com.apple.mobilesafari') >>> print(dev.app_state('com.apple.mobilesafari')["value"]) # --> output is 1
-
app_current
()[源代码]¶ get the app current
Notes
Might not work on all devices
返回: - {“pid”: 1281,
- ”name”: “”, “bundleId”: “com.netease.cloudmusic”}
返回类型: current app state dict, eg
-
get_ip_address
()[源代码]¶ get ip address from webDriverAgent
返回: raise if no IP address has been found, otherwise return the IP address
-
is_locked
()[源代码]¶ Return True or False whether the device is locked or not
Notes
Might not work on some devices
返回: True or False
-
unlock
()[源代码]¶ Unlock the device, unlock screen, double press home
Notes
Might not work on all devices
返回: None
-
alert_accept
()[源代码]¶ Alert accept-Actually do click first alert button
Notes
Might not work on all devices
返回: None
-
alert_dismiss
()[源代码]¶ Alert dissmiss-Actually do click second alert button
Notes
Might not work on all devices
返回: None
-
alert_wait
(time_counter=2)[源代码]¶ if alert apper in time_counter second it will return True,else return False (default 20.0) time_counter default is 2 seconds
Notes
Might not work on all devices
返回: None
get alert buttons text. .. rubric:: Notes
Might not work on all devices
返回: (“设置”, “好”) 返回类型: # example return
-
alert_exists
()[源代码]¶ get True for alert exists or False.
Notes
Might not work on all devices
返回: True or False
-
alert_click
(buttons)[源代码]¶ when Arg type is list, click the first match, raise ValueError if no match
eg. [“设置”, “信任”, “安装”]
Notes
Might not work on all devices
返回: None
-
home_interface
()[源代码]¶ get True for the device status is on home interface.
- Reason:
- some devices can Horizontal screen on the home interface
Notes
Might not work on all devices
返回: True or False
-
clear_app
(package)¶
-
list_app
(**kwargs)¶
-
shell
(*args, **kwargs)¶
-
uninstall_app
(package)¶