繁体   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