繁体   English   中英

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

[英]iOS app wont launch when appium server is started programmatically

这有点奇怪的情况。 如果我手动启动appium GUI服务器并运行appium java测试,则会打开iOS模拟器,并且该应用程序将按预期启动。 问题是,当从Java代码启动服务器时,连接成功,模拟器打开,但是即使可以坐在模拟器上看到应用程序也无法启动。

测试失败,并显示以下错误:

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显示错误:

<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}

我的代码:

  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();


 }

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM