[英]iOS app wont launch when appium server is started programmatically
It's a bit of a weird situation. 这有点奇怪的情况。 If I manually start the appium GUI server and run my appium java test, iOS simulator opens and the app launches as expected. 如果我手动启动appium GUI服务器并运行appium java测试,则会打开iOS模拟器,并且该应用程序将按预期启动。 The problem is when the server is started from java code, the connection is successful, the simulator opens, but the app doesn't launch, even though it can be seen sitting there on the simulator. 问题是,当从Java代码启动服务器时,连接成功,模拟器打开,但是即使可以坐在模拟器上看到应用程序也无法启动。
The test fails with the error: 测试失败,并显示以下错误:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: simctl error running 'uninstall': An error was encountered processing the command (domain=LSApplicationWorkspaceErrorDomain, code=111):
The operation couldn’t be completed. (LSApplicationWorkspaceErrorDomain error 111.)
CoreSimulator.log shows the error: CoreSimulator.log显示错误:
<Error>: uninstallApplication:withOptions:error:: Error Domain=LSApplicationWorkspaceErrorDomain Code=111 "(null)" UserInfo={optionsDict={
SimulatorRootPath = "/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.3.simruntime/Contents/Resources/RuntimeRoot";
SimulatorUserPath = "/Users/Library/Developer/CoreSimulator/Devices/4C54BEC0-5A37-418A-8C32-CC9168538FBF/data";
}, CFBundleIdentifier=com.apple.test.WebDriverAgentRunner-Runner}
My code: 我的代码:
private AppiumDriverLocalService service;
WebDriver driver;
@BeforeClass(alwaysRun=true)
public void startServer() throws InterruptedException, MalformedURLException {
AppiumDriverLocalService service = AppiumDriverLocalService
.buildService(new AppiumServiceBuilder().usingDriverExecutable(new File("/usr/local/Cellar/node/8.5.0/bin/node"))
.withAppiumJS(new File("/Users/node_modules/appium/build/lib/main.js"))
.withLogFile(new File("./AppiumServerlog.txt")));
service.start();
}
@Test
public void testStartPage() throws InterruptedException, MalformedURLException {
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("platformName", "iOS");
cap.setCapability("platformVersion", "10.3");
cap.setCapability("deviceName", "iPhone 7");
cap.setCapability("browserName", "");
cap.setCapability("app", "/path/to/file");
cap.setCapability("noReset", true);
driver = new RemoteWebDriver(new URL("http://0.0.0.0:4723/wd/hub"), cap);
@AfterClass(alwaysRun=true)
public void tearDown() {
service.stop();
driver.quit();
}
The Appium server needs few seconds to start, so provide delay next line of the server start command. Appium服务器需要几秒钟来启动,因此请在服务器启动命令的下一行提供延迟。
driver = new RemoteWebDriver(new URL("http://0.0.0.0:4723/wd/hub"), cap);
Thread.sleep(10000);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.