如果scrollHeight大于height-则元素具有滚动条.If scrollHeight is greater than height - then an element has a scrollbar.在protractor中,我们需要比较getAttribute('height')和getAttribute('scrollHeight')的已解决承诺.让我们做一个可重用的函数,并通过then()来解决两个诺言之一,让expect()来解决第二个诺言:In protractor we need to compare the resolved promises of getAttribute('height') and getAttribute('scrollHeight'). Let's make a reusable function and resolve one of two promises via then() letting expect() to resolve the second:function elementHasScroll(element) { element.getAttribute('height').then(function (height) { expect(element.getAttribute('scrollHeight')).toBeGreaterThan(height); });};其中toBeGreaterThan()方便的匹配器是 jasmine-matchers 第三方的一部分. where toBeGreaterThan() handy matcher is a part of jasmine-matchers third-party. 这篇关于期望元素具有滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-16 19:04