【发布时间】:2019-03-19 20:32:38
【问题描述】:
我想使用 testcafe console.log 打印我在网页上找到的变量的字符串值。我正在尝试获取我用选择器标识的对象的文本值(下面的 frameSizetext)。该脚本正在运行,并且 .contains() 方法验证它是否包含我正在检查的文本,但我还想将文本值打印到控制台,这将有助于更轻松地调试脚本。
`test('Test ==> Check size details are listed for article ', async t
=> {
const form = main.searchForm
const list = main.sunglassesList
const firstRow = list.getRowByIndex(0)
const articlesList = main.articlesList
const frameSizeText = articlesList.frameSize.innerText
await t
.wait(1000)
.typeText(form.searchField, '44444')
.click(form.submitButton)
.expect(main.sunglassesList.list.innerText)
.contains('SKODA Bar')
.click(firstRow.element)
.expect(frameSizeText, 'Text matches ' +frameSizeText)
.contains('44/22-144', 'checking framesize text')
console.log("[DEBUG], Framesize is detailed as:"
+frameSizeText.toString())
})`
✓ Test ==> Check frame color is detailed for article
[DEBUG], Framesize is detailed as:[object Object]
✓ Test ==> Check size details are listed for article
我正在寻找的文本目前正在打印为“[object Object]”,见上文。如何打印这个对象的字符串值?
【问题讨论】:
标签: javascript testing automated-tests console.log testcafe