简体   繁体   English

TestCafe - 断言不起作用(测试的对象必须是数组等)

[英]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.

相关问题 Mithril.js:“组件模板必须返回虚拟元素,而不是数组,字符串等”是什么意思? - Mithril.js: What does “Component template must return a virtual element, not an array, string, etc.” mean? Nodejs:[ERR_INVALID_ARG_TYPE]:“data”参数必须是string类型或者Buffer的实例等收到Array的实例 - Nodejs: [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, etc. Received an instance of Array jQuery:在dblclick上触发事件不起作用(但在keyup等上起作用) - jQuery: Triggering event on dblclick not working (but working on keyup etc.) 如何使用附加到每个条目的 object 值创建递增的对象数组 User1、User2 等? - How do i create an incrementing array of objects, User1, User2 etc. with object values attached to each entry? 执行 TestCafe 断言的正确方法是什么 - What is the correct way to perform TestCafe assertions TestCafe - 选择器/断言可以并行运行吗? - TestCafe - Can selectors / assertions be run in parallel? apply,arguments,bind等是javascript对象内部原型的一部分吗? - Are apply, arguments, bind, etc. part of the internal prototype of a javascript object? 中断数组循环功能的循环(map,forEach等) - Break the loop of an Array looping function (map, forEach, etc.) HandlebarsJS:获取每个数组的元素i,然后获取元素j等? - HandlebarsJS : Get elements i of each array, then element j, etc.? 数组在 reduce()、map() 等中可用的原因是什么? - What is the reason array is available inside reduce(), map(), etc.?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM