我正在尝试创建XCTestCase来测试我的大纲视图中的重新排序(在OS应用程序中)。当我使用UI测试记录功能时,Xcode会打印以下内容:
window.outlines.staticTexts["<cell which I want to move>"].click()我尝试拖动单元格内或外部大纲视图,Xcode生成相同的无用代码。
有人知道如何在Xcode 7中正确测试拖放吗?
发布于 2016-01-07 19:44:27
不确定这是否是新的,但在Xcode 7.2中,如果您查看XCUIElement的头部,就会发现OS有一个clickForDuration(thenDragToElement:)函数。
这是头版的..。
/*!
* Clicks and holds for a specified duration (generally long enough to start a drag operation) then drags
* to the other element.
*/
public func clickForDuration(duration: NSTimeInterval, thenDragToElement otherElement: XCUIElement)发布于 2018-09-12 15:18:25
使用Xcode 9.4.1 Swift:
func press(forDuration duration: TimeInterval, thenDragTo otherElement: XCUIElement)示例:
let ele: XCUIElement = XCUIApplication()!.otherElements.matching(identifier: "element_identifier").element(boundBy: 0)
ele.press(forDuration: <timeIntervalInSec>, thenDragTo: <destination_XCUIElement>)参考:API文档
发布于 2015-12-22 07:44:13
同样的问题。没有解决办法。看起来可访问性不支持d d,而Apple说:为拖放操作提供替代方案。
https://stackoverflow.com/questions/32094410
复制相似问题