簡體   English   中英

Appium IOS 測試在手動啟動服務器時運行,但在通過 AppiumDriverLocalService 啟動服務器時不運行

[英]Appium IOS tests running when server started manually but not when server is started via AppiumDriverLocalService

嘗試在 Mac Mini(M1 芯片,如果相關)上的 iOS(模擬器)上運行 Appium 自動化腳本。 當我運行測試時,手動啟動 Appium 服務器時它們工作得很好(在終端中輸入“appium”並以這種方式啟動)。 但是,當我嘗試以編程方式啟動 appium 服務器時,被測應用程序無法啟動,並出現以下錯誤:

2021-02-17 03:41:27:256 [W3C]       WebDriverAgentRunner-Runner.app (19077) encountered an error (Failed to load the test bundle. If you believe this error represents a bug, please attach the result bundle at /Users/sagolGoru20/Library/Developer/Xcode/DerivedData/WebDriverAgent-gkbkvswlszzhhbevpokpwtrjdxxq/Logs/Test/Test-WebDriverAgentRunner-2021.02.16_22-41-22--0500.xcresult. (Underlying Error: **The bundle “WebDriverAgentRunner” couldn’t be loaded because it doesn’t contain a version for the current architecture. The bundle doesn’t contain a version for the current architecture. Try installing a universal version of the bundle.** dlopen_preflight(/Users/sagolGoru20/Library/Developer/Xcode/DerivedData/WebDriverAgent-gkbkvswlszzhhbevpokpwtrjdxxq/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/WebDriverAgentRunner): no suitable image found.  Did find:
2021-02-17 03:41:27:256 [W3C]   /Users/sagolGoru20/Library/Developer/Xcode/DerivedData/WebDriverAgent-gkbkvswlszzhhbevpokpwtrjdxxq/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/WebDriverAgentRunner: mach-o, but wrong architecture))

這是完整的appium日志: https://gist.githubusercontent.com/fida10/44344b223874310cf296d38a95d4268f/raw/316855b619129680eeaa6519a446a436d0699cd6。

我最初認為這是 xcode 或 WDA 的問題,但如果是這種情況,無論如何啟動 Appium,測試都會失敗,並且如前所述,當手動啟動 Appium(通過終端)時,測試完全通過,因此從 Java 執行時可能是 PATH 或環境變量的問題,但不確定。

這是我用來以編程方式啟動服務器的代碼:

        HashMap<String, String> environment = new HashMap();
        environment.put("PATH", "/usr/local/bin:" + System.getenv("PATH"));

        AppiumDriverLocalService server = AppiumDriverLocalService
                .buildService(new AppiumServiceBuilder()
                        .withEnvironment(environment)
                        .usingDriverExecutable(new File("//opt/homebrew/Cellar/node/15.8.0/bin/node"))
                        .withAppiumJS(new File("//Users/sagolGoru20/.npm-packages/lib/node_modules/appium/build/lib/main.js"))
                        .usingAnyFreePort()
                        .withArgument(GeneralServerFlag.SESSION_OVERRIDE)
                        .withLogFile(new File("//Users/sagolGoru20/Programming/JavaProjects/MavenProjects/MobileAutomationProjects/firstAppiumProject/appiumLog.txt"))
                );
        server.start();

正如 appium 日志顯示的那樣,服務器似乎啟動得很好,但隨后拋出了上述錯誤,所以我認為問題可能在於我如何構建 AppiumDriverLocalService object。

我按照本教程構建 AppiumDriverLocalService: https://appiumpro.com/editions/71-starting-an-appium-server-programmatically-using-appiumservicebuilder

這是項目代碼。 這是一個簡單的項目,我只需單擊“允許”按鈕(第 26 行):https://gist.github.com/fida10/bec187a516fc32f907f9772526

當我注釋掉 AppiumDriverLocalService 服務器 object(第 46 到 58 行)並通過取消注釋第 60 行來啟動時,測試運行正常。

任何幫助將不勝感激。

能夠通過在 XCode 構建設置中將“僅構建活動架構”下的所有選項設置為“否”來解決它。 詳細信息: https://github.com/appium/java-client/issues/1444#issuecomment-781078298

希望這有助於嘗試使用新 M1 芯片在 Mac 設備上運行 XCUITests 的人。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM