【发布时间】:2014-11-24 23:26:11
【问题描述】:
我正在尝试使用 Nightwatch.js 断言/验证属性的多个元素。
我尝试使用 selenium 的“元素”命令,但它似乎实际上并没有返回标签。
browser.elements('css selector','icon_checkmark', function (result) {
this.verify.attributeEquals(result.value, 'aria-hidden', 'true');
})
控制台输出此错误:
Testing if attribute aria-hidden of <[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]> equals "true".
Element could not be located. - expected "true" but got: null
ERROR: Unable to locate element: "[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]" using: css selector
它似乎找到了正确的东西,因为应该有 6,但不知何故我读出了错误的东西?结果.value[0] 的 Console.log 只给出了 { ELEMENT: '19' } 这似乎是正确的。
知道我怎样才能完成这项工作吗?我想检查具有 icon_checkmark 类的所有元素是否具有属性 aria-hidden="true"。
【问题讨论】:
-
code.google.com/p/selenium/wiki/JsonWireProtocol#/session/… – “返回:{Array.} 定位元素的 WebElement JSON 对象列表。”不幸的是,我不知道如何通过“服务器分配给元素的不透明 ID”来获取实际元素。
-
我也想不通,但我更进一步:github.com/nightwatchjs/nightwatch/issues/512
标签: javascript selenium accessibility functional-testing nightwatch.js