简体   繁体   English

Appium IOS 测试在手动启动服务器时运行,但在通过 AppiumDriverLocalService 启动服务器时不运行

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

Attempting to run Appium automation scripts on iOS (simulator) on a Mac Mini (M1 chip, if that's relevant).尝试在 Mac Mini(M1 芯片,如果相关)上的 iOS(模拟器)上运行 Appium 自动化脚本。 When I run the tests, they work just fine when the Appium server is started manually (typing "appium" into the terminal and starting it that way).当我运行测试时,手动启动 Appium 服务器时它们工作得很好(在终端中输入“appium”并以这种方式启动)。 However, when I attempt to start the appium server programmatically, the application under test fails to launch, with the following error:但是,当我尝试以编程方式启动 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))

Here's the full appium log: https://gist.githubusercontent.com/fida10/44344b223874310cf296d38a95d4268f/raw/316855b619129680eeaa6519a446a436d0699cd6/failedLog.txt这是完整的appium日志: https://gist.githubusercontent.com/fida10/44344b223874310cf296d38a95d4268f/raw/316855b619129680eeaa6519a446a436d0699cd6。

I originally thought that this was an issue with xcode or WDA, but if that were the case, the tests would fail no matter how Appium was started, and as mentioned previously, the tests pass perfectly fine when Appium is started manually (via terminal), so it might be an issue with the PATH or environment variables upon execution from Java, not sure though.我最初认为这是 xcode 或 WDA 的问题,但如果是这种情况,无论如何启动 Appium,测试都会失败,并且如前所述,当手动启动 Appium(通过终端)时,测试完全通过,因此从 Java 执行时可能是 PATH 或环境变量的问题,但不确定。

Here is the code I am using to start the server programmatically:这是我用来以编程方式启动服务器的代码:

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

As the appium log shows, the server seems to be started fine but then throws the above error, so I think the issue may be with how I'm building the AppiumDriverLocalService object.正如 appium 日志显示的那样,服务器似乎启动得很好,但随后抛出了上述错误,所以我认为问题可能在于我如何构建 AppiumDriverLocalService object。

I followed this tutorial in building AppiumDriverLocalService: https://appiumpro.com/editions/71-starting-an-appium-server-programmatically-using-appiumservicebuilder我按照本教程构建 AppiumDriverLocalService: https://appiumpro.com/editions/71-starting-an-appium-server-programmatically-using-appiumservicebuilder

Here is the project code.这是项目代码。 It's a simple project, I'm just clicking on an "Allow" button (line 26):https://gist.github.com/fida10/bec187a516fc32f907f97725263a7206这是一个简单的项目,我只需单击“允许”按钮(第 26 行):https://gist.github.com/fida10/bec187a516fc32f907f9772526

When I comment out the AppiumDriverLocalService server object (lines 46 to 58) and instead launch by uncommenting line 60, the test runs properly.当我注释掉 AppiumDriverLocalService 服务器 object(第 46 到 58 行)并通过取消注释第 60 行来启动时,测试运行正常。

Any help would be greatly appreciated.任何帮助将不胜感激。

Was able to solve it by setting all options under "Build Active Architecture only" to "no", in XCode build settings.能够通过在 XCode 构建设置中将“仅构建活动架构”下的所有选项设置为“否”来解决它。 Details: https://github.com/appium/java-client/issues/1444#issuecomment-781078298详细信息: https://github.com/appium/java-client/issues/1444#issuecomment-781078298

Hopefully this helps someone trying to run XCUITests on Mac devices with the new M1 chip.希望这有助于尝试使用新 M1 芯片在 Mac 设备上运行 XCUITests 的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 以编程方式启动appium服务器时,iOS应用不会启动 - iOS app wont launch when appium server is started programmatically AppiumServerHasNotBeenStartedLocallyException: 本地 appium 服务器尚未启动 - AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started 启动服务器时从数据库加载值 - load the value from database when the server is started 在服务器中启动应用程序时,printStackTrace()日志的位置 - Location of printStackTrace() log when application is started in server 如果由AppiumServiceBuilder启动appium服务器,如何启用--no-reset - How to enable --no-reset if appium server is started by AppiumServiceBuilder 通过Eclipse启动应用程序和服务器时未创建Tomcat日志 - Tomcat log is not created when the application and server are started through eclipse WebLogic 服务器作为 Windows 服务启动时如何远程调试它 - How to remote debug WebLogic server when it started as Windows Service 仅当glassfish服务器启动时,如何自动运行程序? - How to run a program automatically when just glassfish server is started? 当独立服务器以管理员权限启动时,客户端转换失败 - Client conversion fails when Standalone Server started with Administrator permissions 以编程方式启动Appium时,Android驱动程序无法初始化 - Appium when started Programmatically, the Android Driver fails to Initialize
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM