繁体   English   中英

量角器:跟进另一个有关如何处理在页面对象模型中返回数组的定位符的线程

[英]protractor: follow up to another thread regarding how to handle locators that return array in page object model

我对此线程有一个后续问题: 页面对象的正确量角器语法是什么?

这篇文章有助于理解页面对象,尤其是:“ Xotabu4”的答案,但我遇到了稍微不同的问题。

有人可以帮我理解如何处理页面对象,该对象将返回用户在上述链接中引用的相似模型中的元素数组。 例如,element.all($$)返回一个数组,我必须将数组中的每个元素与特定文本进行比较。 如何在以上超链接提到的模型中构建结构

假设有一个下拉列表,可通过<select>选择目标工具,我们需要使用正确的文本来验证所有选项。

<select class="destination">
  <option></option>
  ....
</select>

this.select_destination = element(by.css('select.destination'));

readDestinationOptionsText() {
  return this.select_destination.all(by.css('option')).getText();
}

verifyDestinationOptionsText(expectTexts) {
  return readDestinationOptionsText().then(function(actualTexts){
     return expect(actualTexts.join(',')).toEqual(expectTexts.join(','));
  });
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM