AngularJS:警報彈出量角器:gettext的()不起作用[無法從跨度獲取文本標題]
<div class="modal-header">
<h3>
<span class="firefinder-match" data-ng-show="dialog.stopOrService === 'STOP'" data-translate-values="{"days":"ALL_DAYS","time":"2015-06-20T08:39:46.654Z","stopOrService":"STOP","stopName":"Fairbairn Av after War Memorial Service [3473]","serviceList":[{"serviceNumber":"910","id":"6350571294206984726","name":"910 City via Majura Business Park(Net14NoAir"}],"selectedService":null,"receiveSituations":false,"processing":false}" data-translate="liveDepartures.alerts.addModal.stopHeader">Add a regular alert for upcoming buses at Fairbairn Av after War Memorial Service [3473]</span>
<span class="firefinder-match ng-hide" data-ng-show="dialog.stopOrService === 'SERVICE'" data-translate-values="{"days":"ALL_DAYS","time":"2015-06-20T08:39:46.654Z","stopOrService":"STOP","stopName":"Fairbairn Av after War Memorial Service [3473]","serviceList":[{"serviceNumber":"910","id":"6350571294206984726","name":"910 City via Majura Business Park(Net14NoAir"}],"selectedService":null,"receiveSituations":false,"processing":false}" data-translate="liveDepartures.alerts.addModal.serviceHeader">Add a regular alert for route </span>
</h3>
</div>
斷言:使用的getText()
var pageHeader = element(by.css('.modal-header > h3 > span'))
expect(pageHeader.getText()).toContain('Add a regular alert');
pageHeader.getText().then(function(text){
console.log("++++++++++++++++++++++++++++++++++++++" +text);
});
問題:無法從元素中獲取文本 我嘗試了很多方法來識別模型標題上的「文本」,但無法成功獲取來自元素的文本。問題看起來像元素沒有被識別。有人可以幫我解決這個問題。
你能引用實際的錯誤嗎?給'then>添加一個錯誤處理程序並打印錯誤。 – Sulthan
CSS選擇器看起來正確。控制檯上打印什麼內容?你確定頁面上沒有更多的'模態頭'元素嗎?(例如不可見)? – alecxe
'失敗: 1)現場離港董事會作爲用戶,我可以在公共汽車站添加警報 消息: 預計將包含'添加常規警報'。 Stacktrace: 錯誤:在[對象對象]處的預期失敗 。(C:\ Users \ Tests \ tests \ AcceptanceScenariosLDB.js:71:42) at [object Object]位於C:\ Users \ Tests \ node_modules \ protractor \ node_modules \ jasminewd \ index.js:94:14 。 webdriver.promise.ControlFlow.runInNewFrame_'' –
MathurS