当一个复选框AngularJS端到端测试检查如何验证? [英] How to validate when a checkbox is checked in AngularJS e2e tests?

查看:130
本文介绍了当一个复选框AngularJS端到端测试检查如何验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图走出 AngularJS端到端测试和我卡住确定是否一个复选框被选中。

I've been trying out the AngularJS e2e tests and am getting stuck determining whether or not a checkbox is checked.

我使用了端到端的复选框,输入测试作为样本(见的端到端测试的选项卡中的的示例的)。

I used the end to end test for the checkbox input as a sample (see the End to end test tab in the Example).

HTML片段:

值1:<输入类型=复选框NG模型=值1> < BR />

控制器片段:

function Ctrl($scope) {
  $scope.value1 = true;
}

这里是我的尝试:

1)预期(结合('值1'))toEqual('真正');

本工作在样品结束长达结束测试为值1 显示在屏幕上以 {{值1} 。如果你测试这个本地和删除`{{值1}}绑定测试失败。在大多数我的现实世界的例子,我不显示在屏幕任意位置的复选框值。

This works in the sample end to end test as long as value1 is displayed on screen with {{value1}}. If you test this locally and remove `{{value1}} the binding test fails. In most of my real-world examples I am not displaying the checkbox value on the screen anywhere.

2)预期(输入('值1')VAL())toEqual('真正');

该值将始终默认为,并没有涉及到是否不复选框在选中状态(从拍摄的this~~V帖子)。

The value will always default to on and is not related to whether or not the checkbox is in a checked state (taken from this post).

注意:它看起来像角端到端测试将与量角器在未来取代(看到的文档

Note: It looks like the Angular E2E testing will be replaced with Protractor in the future (see the docs)

推荐答案

我upvoted这个问题,因为我有同样的问题。
我用以下解决方法在我的测试,但我希望看到更好的办法。

I upvoted this question as I had the same issue. I used following workaround in my test, but I'm hoping to see the better way.

expect( element('input[ng-model="value1"]').attr('checked') ).toBeTruthy();

这篇关于当一个复选框AngularJS端到端测试检查如何验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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