当appium服务器以编程方式启动时,iOS应用程序将无法启动

时间:2017-10-08 06:06:41

标签: java appium-ios

这有点奇怪。如果我手动启动appium GUI服务器并运行我的appium java test,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();


 }

1 个答案:

答案 0 :(得分:0)

Appium服务器需要几秒钟才能启动,因此请在服务器启动命令的下一行提供延迟。

driver = new RemoteWebDriver(new URL("http://0.0.0.0:4723/wd/hub"), cap);
Thread.sleep(10000);