gpt4 book ai didi

ios - 使用 UI 测试滚动单元格

转载 作者:可可西里 更新时间:2023-11-01 04:10:38 24 4
gpt4 key购买 nike

有没有类似的方法

- (void)scrollByDeltaX:(CGFloat)deltaX deltaY:(CGFloat)deltaY;

iOS 版?

我认为上面的方法只适用于 OSX。我想根据提供的增量值滚动我的表格 View 。

提前致谢。

最佳答案

在 iOS 上,您可以使用 XCUIElement.press(forDuration:thenDragTo:)如果你想移动元素。

要根据相对坐标移动,您可以获得元素的XCUICoordinate,然后使用XCUICoordinate.press(forDuration:thenDragTo:)。 .

let table = XCUIApplication().tables.element(boundBy:0)

// Get the coordinate for the bottom of the table view
let tableBottom = table.coordinate(withNormalizedOffset:CGVector(dx: 0.5, dy: 1.0))

// Scroll from tableBottom to new coordinate
let scrollVector = CGVector(dx: 0.0, dy: -30.0) // Use whatever vector you like
tableBottom.press(forDuration: 0.5, thenDragTo: tableBottom.withOffset(scrollVector))

或者在 Objective-C 中:

XCUIApplication *app = [[XCUIApplication alloc] init];
XCUIElement *table = [app.tables elementBoundByIndex: 0];

// Get the coordinate for the bottom of the table view
XCUICoordinate *tableBottom = [table coordinateWithNormalizedOffset:CGVectorMake(0.5, 1.0)];

// Scroll from tableBottom to new coordinate
CGVector scrollVector = CGVectorMake(0.0, -30.0); // Use whatever vector you like
[tableBottom pressForDuration:0.5 thenDragToCoordinate:[tableBottom coordinateWithOffset:scrollVector]];

关于ios - 使用 UI 测试滚动单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40923929/

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