gpt4 book ai didi

javascript - Object.keys 不会将方法名称打印为属性

转载 作者:行者123 更新时间:2023-11-29 18:04:40 26 4
gpt4 key购买 nike

我正在使用 Protractor 使用 xpath data-grid[@name="someTable"] 选择一个表,然后使用类名 someColumn 选择一个单元格专栏。

var cells = element(by.xpath('//data-grid[@name="someTable"]').all(by.css('.someColumn'))

当我执行 Object.keys(cells)(或)Object.getOwnPropertyNames(cells) 时,它不显示 count属性(property)。

Object.keys 输出,

ptor_,getWebElements,actionResults_,locator_,click,sendKeys,getTagName,getCssValue,getAttribute,getText,getSize,getLocation,isEnabled,isSelected,submit,clear,isDisplayed,getOuterHtml,getInnerHtml,getId,getRawId

当我这样做的时候,

expect(numberOfRows.count()).toBe(2)

有效

为什么在打印cells 对象的属性时,count 函数不显示?

最佳答案

这是因为 Protractor 中的 count() 不是 element/elements.all() 的属性。 count() 函数在 ElementArray 之上运行,并通过计算具有指定定位器的元素数来返回值。 Check the implementation of count() .

Its just a wrapper over element locator which puts in all the located elements into an array and then returns the array's length as count in the form of promise.

希望这对您有所帮助。

关于javascript - Object.keys 不会将方法名称打印为属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32281997/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com