不知为何,无法使用driver.runAppInBackground(Duration.ofSeconds(10))
这条命令,每次都会报错
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Error Domain=com.facebook.WebDriverAgent Code=1 "Timeout waiting until SpringBoard is visible" UserInfo={NSLocalizedDescription=Timeout waiting until SpringBoard is visible}
于是参考appium相关文档,找到了解决方法
http://appium.io/docs/en/writing-running-appium/ios/ios-xctest-mobile-apps-management/
实现将App置于后台,具体代码如下:
JavascriptExecutor jse = (JavascriptExecutor) driver;
Map<String, Object> params = new HashMap<>();
params.put("bundleId", "com.kingsoft.www.office.wpsoffice");
final boolean wasRunningBefore = (Boolean)jse.executeScript("mobile: terminateApp", params);
实现启动置于后台的App,具体代码如下:
JavascriptExecutor jse = (JavascriptExecutor) driver;
Map<String, Object> params = new HashMap<>();
params.put("bundleId", "com.kingsoft.www.office.wpsoffice");
jse.executeScript("mobile: activateApp", params);
可以启动任何一个知道bundleid的App