gpt4 book ai didi

earlgrey - 在 EarlGrey 中,我如何访问我正在与之交互的元素对象?

转载 作者:行者123 更新时间:2023-12-01 13:43:09 24 4
gpt4 key购买 nike

在 EarlGrey 中,我如何访问我正在与之交互的元素对象,例如我想访问我刚刚点击的 UIButton。

最佳答案

EarlGrey 不返回(指向)元素,因为返回的 View /元素在交互完成后可能不存在,而且它可能导致难以检测错误,因为持有对 View 的强引用可以修改 View 的生命周期。但是,您可以在交互发生时使用 GREYActionBlock 访问该元素。

- (void)testFoo {
[[EarlGrey selectElementWithMatcher:grey_FooElementMatcher()]
performAction:[GREYActionBlock actionWithName:@"bar"
performBlock:^(id element, NSError *__strong *errorOrNil) {
[element doWhatever];
return YES; // Return YES for success, NO for failure.
}
]];
}

关于earlgrey - 在 EarlGrey 中,我如何访问我正在与之交互的元素对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38231073/

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