在Xcode UITesting中进行精确的像素拖动

在Xcode UITesting中进行精确的像素拖动,xcode,xcode-ui-testing,ui-testing,Xcode,Xcode Ui Testing,Ui Testing,我知道拖动元素的默认方式: let start = savingsCell.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0)) let finish = savingsCell.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: -80)) start.press(forDuration: 0, thenDragTo: finish) 这里的问题是,拖动在UITableView中

我知道拖动元素的默认方式:

let start = savingsCell.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0))
let finish = savingsCell.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: -80))
start.press(forDuration: 0, thenDragTo: finish)

这里的问题是,拖动在UITableView中继续,超出了我指定的80点。有没有一种方法可以在没有物理的情况下精确拖动这个数量的物体?

通过使用XUICoordinate上的方法从起点坐标创建终点坐标,可以使拖动精确到点数

let start = savingsCell.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0))
let finish = start.withOffset(CGVector(dx: 0, dy: -80))
start.press(forDuration: 0, thenDragTo: finish)
规格化方法的向量与元素的大小有关,但coordinatewithOffset:的向量使用绝对点值。不是像素-所以在使用@2x或@3x资产的设备上,这实际上分别是160像素或240像素