回答
這裏是我寫來測試彈出存在階級和以確保文本在標題和正文中是正確的:
var TestUtilities = function(){
this.popup = element(by.css('.popup-container.popup-showing.active'));
//Tests to see if $ionicPopup.alert exists
this.popupShouldExist = function() {
expect(this.popup.isDisplayed()).toBeTruthy();
};
//Tests to see if $ionicPopup.alert contains the text provided in the argument exists in the header
this.popupContainsHeaderText = function (text) {
this.popupShouldExist();
expect(this.popup.element(by.css('.popup-head')).getText()).toMatch(text);
};
//Tests to see if $ionicPopup.alert contains the text provided in the argument exists in the body
this.popupContainsText = function (text) {
this.popupShouldExist();
expect(this.popup.element(by.css('.popup-body')).getText()).toMatch(text);
};
};
module.exports=TestUtilities;
也查看本網站更多關於在量角器中測試離子的問題,它談到如何檢查彈出是否存在:http://gonehybrid.com/how-to-write-automated-tests-for-your-ionic-app-part-3/
完美答案!這完全回答了我的問題,包括如何檢查標題和正文中的文本,都包含在一個很好的通用實用程序類中。謝謝!! –
離子彈出只是由DOM元素組成,所以你應該能夠使用普通的定位器來查找/測試它們。由於它們不是由警報組成的,因此您鏈接的問題的解決方法可能無用。
我明白了 - 我看到很多問題都試圖以非常複雜的方式來完成,但最終我嘗試了這一點,結果證明這很簡單。
檢查你的元素,並找到自己的NG-重複值,然後
var button = element(by.repeater('button in buttons')).getText()
您還需要有瀏覽器坐在莫名其妙的一對夫婦秒,所以它不解析而測試離子彈出實際上並不存在。
爲此,browser.sleep(3000);
這就是它!但是,獲取那裏的另一個按鈕被證明是一個小問題。 var button = element(by.repeater('button in buttons')).get(0)
或.get(1)
return undefined不是函數。
如果您喜歡,請接受答案!如果我弄清楚如何獲得其他按鈕,我會在這裏發佈。
var popup = element(by.css('.popup-container.popup-showing.active'));
而且在測試::
這不適合我。我得到了:NoSuchElementError:找不到使用定位器的元素:by.repeater(「按鈕中的按鈕」) –
你必須檢查元素,看看它們用於中繼器,即香蕉香蕉? – realization
我已經通過設置彈出變量,如下所示成功測試離子彈出窗口
expect(popup.isDisplayed()).toBeTruthy();
非常感謝!這工作。另見http://gonehybrid.com/how-to-write-automated-tests-for-your-ionic-app-part-3/ –
- 1. 在等待音樂加載時離子旋轉器(離子2 /角2)
- 2. 拾音器/系統聲音列表
- 3. 角/離子HTTP響應從服務器
- 4. 選擇器的離子3/4角
- 5. Arduino與磁性拾音器接口
- 6. 離子角收音機默認選中
- 7. 離線機上的量角器
- 8. 如何使用量角器識別離子標籤?
- 9. 在量角器離子中不可見的元素
- 10. 離子量角器測試,使得GET請求
- 11. 量角器配置文件不拾取黃瓜步驟定義
- 12. 多個拾音器,每個拾音器都使用多個卡車進行多次交付
- 13. LibGDX - 拾色器
- 14. 拾色器
- 15. 離子角JS
- 16. 使離子角
- 17. 離子Inappbrowser拾取退出事件
- 18. 離子角離子含量填充問題
- 19. 在量角器
- 20. 在量角器
- 21. 量角器element.all
- 22. 與量角器
- 23. 量角器中的cli.js 5.0和如何在量角器中配置量角器
- 24. 使用量角器選擇子div ID
- 25. 量角器測試角$ http攔截器
- 26. CucumberJS /量角器與角CLI
- 27. zkoss拾色器CE
- 28. 虹膜拾色器
- 29. 算法拾色器
- 30. jQuery UI拾色器
您能否提供一個可重複使用的公共站點示例? – alecxe