现在项目有一个功能需要开启/关闭蓝牙和 wifi 的功能,了解到 appium 可以设置手机的网络设置(python)
下面的代码是摘自 webdriver.py 中,但是只能设置 wifi 开关,不能设置蓝牙开关。
找到资料说 Java 中可以用 setNetworkConnection 方式来设置 wifi 和蓝牙,但是 python 中不知道如何设置蓝牙,求大神指教!!
setNetworkConnection(NetworkConnectionSetting connection)
设置手机的网络连接状态,可以开关蓝牙、wifi、数据流量。通过 NetworkConnectionSetting 中的属性来设置各个网络连接的状态。def set_network_connection(self, connectionType): """Sets the network connection type. Android only. Possible values: Value (Alias) | Data | Wifi | Airplane Mode ------------------------------------------------- 0 (None) | 0 | 0 | 0 1 (Airplane Mode) | 0 | 0 | 1 2 (Wifi only) | 0 | 1 | 0 4 (Data only) | 1 | 0 | 0 6 (All network on) | 1 | 1 | 0 These are available through the enumeration `appium.webdriver.ConnectionType`
:Args:
- connectionType - a member of the enum appium.webdriver.ConnectionType
"""
data = {
'parameters': {
'type': connectionType
}
}
return self.execute(Command.SET_NETWORK_CONNECTION, data)['value']