簡體   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