我正在使用 testcafe 版本 - 1.6.1
我正在尝试应用断言来查看元素是否可点击(预计不可点击)。
我找到了元素类名和一个动态同级类,它在浏览器元素中似乎不可点击。
我在下面附上了实际 UI 元素及其 DOM 的两个快照:
由于某种未知原因,该hasclass函数不断失败,因为找不到所需的类。
.expect()buttonEssentialplan30Mb.hasClass('.c-form-plan-box--disabled')).ok()
我在网上搜索最终的“登录模式”,其中包括登录实际成功的验证。问题 -根据我们在团队中决定的 DRY 和编码约定,我们不允许在 Pagemodels 中使用expect(又名断言)。这是当前的登录方法,有时仍然不稳定。我想问你亲爱的 Automators,你是如何设计包括验证在内的登录的?
/**
* Actual login function
*/
async performLogin(): Promise<void> {
console.log(`perform login`);
await t
.typeText(this.Email, username, {
replace: true,
paste: true
})
.typeText(this.Password, password, {
replace: true,
paste: true
})
.click(this.buttonSignIn)
}
/**
* Login validation
*/
async login(): Promise<void> {
await t.wait(7000)
const getURL: any = ClientFunction(() => window.location.href)
let currentURL: string = await getURL()
while (currentURL === basePM.urlLogin) {
this.performLogin()
await t.eval(() => location.reload(true))
currentURL = await getURL()
} …Run Code Online (Sandbox Code Playgroud)