简体   繁体   English

TestCafe 如何检查字段值

[英]TestCafe how to check field value

I would like to write a test using testcafe framework which checks if field has expected value.我想使用 testcafe 框架编写一个测试,该框架检查字段是否具有预期值。 For REST responses I am using RequestLogger, but I have no idea how to check if one of the UI field has expected value.对于 REST 响应,我使用 RequestLogger,但我不知道如何检查 UI 字段之一是否具有预期值。

Any ideas?有任何想法吗?

I would like to check if this field has marked value我想检查这个字段是否有标记值

Here is a sample:这是一个示例:

const errorMsg = Selector('.alert.alert-error').innerText
await t.expect(errorMsg).contains("Login and/or password are wrong.")

Another approach:另一种方法:

if(await Selector('div').withText('testee@tester.com').exists)
    {
        console.log("PASS")
    }
    else
    {
        console.log("FAIL")
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM