【发布时间】:2020-09-16 14:23:07
【问题描述】:
【问题讨论】:
标签: javascript sahi
【问题讨论】:
标签: javascript sahi
答案取决于仪表板的实现。知道应该断言哪些文本会很有帮助。
如果是网络应用程序
我建议使用assertion API 中的_assertContainsText。
Sakuli V2 示例:
(async () => {
const testCase = new TestCase();
try {
await _navigateTo("https://stackoverflow.com");
const contentHeading = await _fetch(_heading1(0, _in(_div("content"))))
await _highlight(contentHeading)
await _assertContainsText("We <3 people who code", contentHeading)
} catch (e) {
await testCase.handleException(e);
} finally {
await testCase.saveResult();
}
})();
如果是原生 UI 应用程序
Sakuli 2 目前无法在屏幕上查找文本。它已计划但尚未完成。确实可以断言屏幕上存在部分。
(async () => {
const testCase = new TestCase();
const url = "https://your-dashboard.com";
const screen = new Region();
const env = new Environment();
try {
await _navigateTo(url);
await env.setSimilarity(0.95);
await screen
.exists("needle.png", 1)
.highlight(1);
} catch (e) {
await testCase.handleException(e);
} finally {
await testCase.saveResult();
}
})();
重用这个 sn-p 时,很可能需要创建一个新的针头图像,因为我从您提供的屏幕截图中截取了它。
【讨论】: