1
私が使用している変数は、ある点の後にが定義されていませんになります。誰かが何が起こっているのか理解するのを助けることができますか?変数にアクセスできない
以下のコードは分度器コードです。
this.searchBy = element(by.model('searchCompanyComponent.searchByValue'));
this.clickTheProvidedValueInSearchByDropdown = function (selectedItem) {
var x = this.searchBy;
this.searchBy.all(by.tagName('option')).filter(function (elem, index) {
return elem.getText().then(function (text) {
return text.toUpperCase().replace(/ |-/g, '') === selectedItem.toUpperCase().replace(/ |-/g, '');
});
}).getText().then(function (text) {
console.info(x); // 1
console.log(this.searchBy); // 2
});
};
console.log(this.searchBy); //3
コンソールログの1と3はロケータオブジェクトを示しますが、2のコンソールログは定義されていません。
この予期しない動作の背景は何ですか?