![](/img/trans.png)
[英]How to create and return an array of objects using protractor page object model design and promises
[英]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.