简体   繁体   English

以编程方式启动appium服务器时,iOS应用不会启动

[英]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.

相关问题 Appium IOS 测试在手动启动服务器时运行,但在通过 AppiumDriverLocalService 启动服务器时不运行 - Appium IOS tests running when server started manually but not when server is started via AppiumDriverLocalService 以编程方式启动Appium时,Android驱动程序无法初始化 - Appium when started Programmatically, the Android Driver fails to Initialize 无法使用Eclipse编辑器在沙箱下以编程方式启动appium服务器 - Unable to launch appium server programmatically under sandbox with eclipse editor 以编程方式运行appium服务器 - Run the appium server programmatically 以编程方式启动Appium服务器 - Starting Appium server programmatically AppiumServerHasNotBeenStartedLocallyException: 本地 appium 服务器尚未启动 - AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started 在Java for iOS中使用高跟鞋类进行的每项测试之前,如何使Appium和应用程序自动启动? - How can I make Appium and the app launch automatically before every test in Java for iOS with heels classes? Appium:尝试在 IOS 设备上安装应用程序时出错 - Appium: Error when trying to install app on IOS device 使用appium在模拟器上启动移动应用 - Launch an mobile app on emulator using appium Appium:自定义android应用在启动时不断崩溃 - Appium: custom android app keeps crashing on launch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM