swift – XCUITest应用程序快捷方式

swift – XCUITest应用程序快捷方式,第1张

概述有没有办法在XCUITests中测试UIApplication快捷方式? 我知道,为了在模拟器中测试3D快捷方式,你需要一个带有强制触摸的触控板,但我想知道我是否可以编写测试我的快捷方式的测试. 看起来是的!但是,您需要公开私有API.从 Facebook’s WebDriverAgent here导出的XCUIElement标头. 或者,如果这是你唯一需要的东西,那就把它暴露出来: @inter 有没有办法在XCUITests中测试UIApplication快捷方式?

我知道,为了在模拟器中测试3D快捷方式,你需要一个带有强制触摸的触控板,但我想知道我是否可以编写测试我的快捷方式的测试.

解决方法 看起来是的!但是,您需要公开私有API.从 Facebook’s WebDriverAgent here导出的XCUIElement标头.

或者,如果这是你唯一需要的东西,那就把它暴露出来:

@interface XCUIElement (Private)    - (voID)forcePress;@end

然后通过转到跳板并获取图标元素see my answer here来强制按下您的图标.

class Springboard {    // this is another private method you'll need to expose (see linked other answer)    static let springboard = XCUIApplication(privateWithPath: nil,bundleID: "com.apple.springboard")    /// Open the 3d touch menu    class func open3dtouchMenu() {        XCUIApplication().terminate() // this may or may not be necessary depending on your desired function / app state        // Resolve the query for the springboard rather than launching it        springboard.resolve()        // Force delete the app from the springboard        let icon = springboard.icons["MyAppname"]        if icon.exists {            icon.forcePress()            // do something with the menu that comes up        }    } }

*我还没有测试过这个.

总结

以上是内存溢出为你收集整理的swift – XCUITest应用程序快捷方式全部内容,希望文章能够帮你解决swift – XCUITest应用程序快捷方式所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/999859.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存