量角器:测试引导程序警报 [英] protractor: testing bootstrap alerts

查看:77
本文介绍了量角器:测试引导程序警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是量角器测试的新手.呆了几个小时.

I'm new to Protractor testing. Been at it for only a few hours.

我有一个使用引导程序警报的角度应用程序.

I have an angular app, using bootstrap alerts.

我如何测试:

  • 页面加载中不存在警报(危险警报)
  • 单击按钮时出现警报(危险警报)
  • 单击另一按钮时出现警报(成功警报)

谢谢!

推荐答案

页面加载中不存在警报(危险警报)

Alert (danger-alert) is not present on page load

您可以使用 isPresent() :

You can use isPresent():

expect(element(by.css('.alert-danger')).isPresent()).toBe(false);

或者,如果元素在那里但不可见,请检查 isDisplayed() :

Or, if the element is there but invisible, check isDisplayed():

expect(element(by.css('.alert-danger')).isDisplayed()).toBe(false);

单击按钮时出现警报(危险警报)

Alert (danger-alert) becomes present on button click

单击按钮,并使用isDisplayed()检查警报是否存在:

Click the button and check if alert is there by using isDisplayed():

element(by.id('myButton')).click()
expect(element(by.css('.alert-danger')).isDisplayed()).toBe(true);

单击另一按钮时出现警报(成功警报)

Alert (success-alert) becomes present on another button click

与上述相同:

element(by.id('myAnotherButton')).click()
expect(element(by.css('.alert-success')).isDisplayed()).toBe(true);

这篇关于量角器:测试引导程序警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆