gpt4 book ai didi

ios - 在应用程序运行后,是否可以在 ui 测试中以编程方式将应用程序移动到 Split View/ slider 上方的 View ?

转载 作者:行者123 更新时间:2023-12-04 14:00:05 25 4
gpt4 key购买 nike

我想测试某些功能在 View 中的拆分/幻灯片中是否有效。

我当前的 ui 测试打开停靠面板并尝试将 iMessage 应用程序拖动到模拟器屏幕的右边框。

看起来任何交互都不适用于与我的应用程序无关的元素。

在应用程序运行后,是否可以在 ui 测试中以编程方式将应用程序移动到拆分 View 或 View 上的滑块?

最佳答案

在较旧的 iOS 版本上是可能的。但是,据我所知,它需要使用坐标手动完成。我在这里找到了一个现有的帮助程序存储库,可能会有所帮助(虽然我没有使用过)https://github.com/superz515/UITestingMultitaskingHelper .
iOS 15 通过多任务支持 UI 使这变得更容易。
enter image description here
enter image description here
enter image description here
如果您观察 XCUITest 进程中的跳板应用程序,您将看到:
默认状态:

Button, 0x600001a02d80, {{1004.5, 667.0}, {14.0, 32.0}}, identifier: 'top-affordance:XCUITestSplit', label: 'XCUITestSplit, Multitasking controls'
点击控件后:
Button, 0x600001431340, {{968.0, 609.0}, {40.0, 40.0}}, identifier: 'top-affordance-full-screen-button', label: 'Full screen', Selected
Button, 0x600001431500, {{968.0, 663.0}, {40.0, 40.0}}, identifier: 'top-affordance-split-view-button', label: 'Split view'
Button, 0x6000014316c0, {{968.0, 717.0}, {40.0, 40.0}}, identifier: 'top-affordance-slide-over-button', label: 'Slide over'
点击选项后:
BannerNotification, 0x600001a38000, {{966.0, 574.5}, {50.0, 217.5}}
Button, 0x600001a380e0, {{966.0, 574.5}, {50.0, 217.5}}, label: 'Split View, Choose another app'
图标示例
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'Files', label: 'Files'
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'Reminders', label: 'Reminders'
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'News', label: 'News'
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'Calendar', label: 'Calendar'
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'Reminders', label: 'Reminders'
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'Maps', label: 'Maps'
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'News', label: 'News'
Icon, {{0.0, 0.0}, {0.0, 0.0}}, identifier: 'Settings', label: 'Settings'
Icon, {{810.5, 155.0}, {95.5, 77.0}}, identifier: 'Shortcuts', label: 'Create XCUITestSplit split view with Shortcuts'
Icon, {{810.5, 353.0}, {95.5, 72.5}}, identifier: 'Contacts', label: 'Create XCUITestSplit split view with Contacts'
Icon, {{810.5, 548.0}, {95.5, 75.0}}, identifier: 'Magnifier', label: 'Create XCUITestSplit split view with Magnifier'
例子
以上可以让您很快进入拆分 View 。
然而,对多少列的更多控制需要移动分隔符,这需要更多的工作(正如我之前提到的),并且您还需要考虑重置状态,以便应用程序不会在拆分 View 中再次启动。
func testExample() throws {
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let app = XCUIApplication()

app.launch()
springboard.buttons["top-affordance:XCUITestSplit"].tap()
springboard.buttons["top-affordance-split-view-button"].tap()
springboard.icons["Shortcuts"].firstMatch.tap()
}
gif (点击观看,原谅方向)
Example

关于ios - 在应用程序运行后,是否可以在 ui 测试中以编程方式将应用程序移动到 Split View/ slider 上方的 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50714778/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com