【发布时间】:2021-12-15 13:29:59
【问题描述】:
我有网站 - https://the-internet.herokuapp.com/notification_message_rendered 点击按钮,在网站上方随机出现“操作成功/n×”或“操作失败,请重试\n×”的通知。 如果通知文本是“操作成功/n×”或“操作不成功,请重试\n×”,我如何让 wdio 期望比较此通知的文本并通过测试? 这是我的代码,我还将 Chai 期望导入为“expectChai”以方便自己:
it("test comparing", async function() {
await browser.url("https://the-internet.herokuapp.com/notification_message_rendered")
const but = await $("p > a")
await but.click()
const t = await $("#flash-messages > div")
await t.waitForDisplayed()
const tx = await t.getText()
await expectChai(tx).to.be.equal("Action successful\n×" || "Action unsuccesful, please try again\n×")})
【问题讨论】:
标签: node.js webdriver-io