简体   繁体   English

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

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

I have a follow up question on this thread here: What's the correct Protractor's syntax for Page Objects? 我对此线程有一个后续问题: 页面对象的正确量角器语法是什么?

This post was useful in understanding page objects especially the answer by : "Xotabu4" but I am running into slightly different problem. 这篇文章有助于理解页面对象,尤其是:“ Xotabu4”的答案,但我遇到了稍微不同的问题。

Could someone please help me understand how would one handle a page object that returns an array of elements in a similar model as quoted in the above link by the user. 有人可以帮我理解如何处理页面对象,该对象将返回用户在上述链接中引用的相似模型中的元素数组。 For example, element.all($$) returns an array and I have to compare each element in the array with a certain text. 例如,element.all($$)返回一个数组,我必须将数组中的每个元素与特定文本进行比较。 How do I structure that in the model mentioned in the above hyperlink 如何在以上超链接提到的模型中构建结构

Assume there is a dropdown list to choose destination implement by <select> , we need to verify all options with correct text. 假设有一个下拉列表,可通过<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