我的框架中有以下代码段可以锁定设备
public void lockScreen() {
try {
if (Driver instanceof AndroidDriver) {
((AndroidDriver) Driver).lockDevice();
} else {
int time = this.getInt(Data, 5);
((IOSDriver) Driver).lockDevice(Duration.ofSeconds(time));
}
System.out.println("Screen locked");
} catch (Exception ex) {
Logger.getLogger(Basic.class.getName()).log(Level.SEVERE, null, ex);
}
}
我正在通过Appium服务器使用Java客户端7.0.0,试图锁定IOS设备(iPad)。从硒中获取错误。该方法尚未实现,但对于Android设备也可以正常使用。请提出解决方法或解决方案,以解决该问题。
下面是异常堆栈跟踪
org.openqa.selenium.WebDriverException: Method has not yet been implemented (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'AMP00006', ip: '192.168.43.71', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '9.0.4'
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities {automationName: XCUITest, browserName: , bundleId: com.apple.mobilecal, databaseEnabled: false, derivedDataPath: /Users/spritz/PreBuiltWDA, deviceName: Spritz's iPad, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: false, noReset: true, platform: ANY, platformName: iOS, takesScreenshot: true, udid: e9f0b277fbecf1bca7cda4b8e3d..., usePrebuiltWDA: true, webStorageEnabled: false}
Session ID: 0769d1ee-f9d9-471f-a6d5-cb3642c86867
at jdk.internal.reflect.GeneratedConstructorAccessor32.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
谢谢
答案 0 :(得分:2)
在Appium documentation中明确提到,iOS或Mac平台不支持此功能。
参考链接:
http://appium.io/docs/en/commands/device/interactions/lock/
支持线程(Appium):
https://discuss.appium.io/t/how-to-lock-and-unlock-iphone-real-device-using-appium/15632/4