我有.expect方法的问题,我找不到一个好的解决方案 . 在我的测试案例中,在某个步骤后,我点击了一个按钮 . 单击此按钮将打开一个包含错误文本"Something went wrong"的新页面 . 现在我想断言那个有选择器 body > app > main > div > error-page > div > h1
的错误文本 .
但每次打开此页面并在控制台中显示错误时我都会收到以下错误“AssertionError:对象测试必须是数组,对象或字符串,但未定义”
我测试了 .expect(errorMessage.value).eql('Something went wrong')
. 我也测试了 .expect(errorMessage.value).contains('Something went wrong')
我也测试了 .expect(errorMessage.exists).ok()
然后"eql"
有什么建议?
1 回答
使用Selector定义errorMessage变量 . 例如:
要么