[英]TestCafe - assertions not working (object tested must be an array etc.)
I have a very simple assertion:我有一个非常简单的断言:
const mappingInput = 'input[data-test="appMS_mappingSite_inputField"]';
const mappingInputValue = "*";
.expect(mappingInput.value).contains(mappingInputValue, 'input contains *', { timeout: 500 })
but when I run test it fails (even though that I know for a fact that input.value contains "*".但是当我运行测试时它失败了(即使我知道 input.value 包含“*”这一事实。
Error message is as follows:错误信息如下:
AssertionError: input contains *: object tested must be an array, a
map, an object, a set, a string, or a weakset, but undefined given
Is there something wrong with my script or what?我的脚本有问题还是什么?
The problem is that the mappingInput
constant is a string.问题是mappingInput
常量是一个字符串。 The string type has no value
property, so the expression mappingInput.value
will always return undefined
.字符串类型没有value
属性,因此表达式mappingInput.value
将始终返回undefined
。 If you are using TestCafe you can access an input value on a test page through the Selector API.如果您使用 TestCafe,您可以通过选择器API 访问测试页面上的输入值。 The following example might suit your needs: https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/selectors/using-selectors.html#define-assertion-actual-value以下示例可能适合您的需求: https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/selectors/using-selectors.html#define-assertion-actual-value
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.