我正在測試的應用使用中繼器輸出列表,並且希望能夠找到特定行並點擊該行內的編輯按鈕。使用現有定位器單擊中繼器內的元素
我使用.filter找到相關的行,然後點擊編輯按鈕,但如果我指定的定位器按鈕,而不是如果我指的是現有的定義這僅適用:
this.editWineButton = element(by.buttonText('edit'));
this.editWine = function (wineName) {
this.wineListEntries.filter(function(row){
return row.element(by.binding('wine.name')).getText().then(function(name){
return name === wineName;
});
}).then(function (elem) {
//THIS WORKS
var button = elem[0].element(by.buttonText('edit'));
//THIS FAILS
//var button = elem[0].editWineButton;
button.click();
});
};
已經爲編輯按鈕定義了定位器,我需要做些什麼才能重新使用篩選器的結果?
當我運行的代碼失敗版本我得到的錯誤
「失敗:無法讀取屬性未定義的‘點擊’」。
我覺得答案肯定是顯而易見的,但我看不出我的錯誤。任何建議將非常受歡迎。