【发布时间】:2021-07-22 01:16:23
【问题描述】:
我正在尝试按文本选择一个元素,但实际文本会发生变化,因为它包含当前时间戳。有没有办法在不对 getAttributes() 进行子字符串搜索的情况下选择它?我不能使用 getAttributes,因为我们还将在 android 上进行测试。
我正在使用的选择:
await expect(element(by.text("James has initiated the chatbot: ShallowFaqChatbot"))).toBeVisible();
元素:
{
hittable: true,
activationPoint: { x: 153.5, y: 14.75 },
normalizedActivationPoint: { x: 0.5, y: 0.5 },
elementFrame: { y: 9, x: 9, width: 307, height: 29.5 },
enabled: true,
elementBounds: { y: 0, x: 0, width: 307, height: 29.5 },
layer: '<CALayer: 0x600002b907c0>',
safeAreaInsets: { right: 0, top: 0, left: 0, bottom: 0 },
visible: true,
elementSafeBounds: { y: 0, x: 0, width: 307, height: 29.5 },
label: 'James has initiated the chatbot: ShallowFaqChatbot - 11:08 am',
className: 'RCTTextView',
frame: { y: 473, x: 34, width: 307, height: 29.5 },
text: 'James has initiated the chatbot: ShallowFaqChatbot - 11:08 am'
}
您可以看到它具有我要查找的文本的属性文本,但是由于“- 11:08 am”,detox 无法抓取它。
【问题讨论】:
标签: xcode react-native testing jestjs detox