(量角器)检查单击时是否禁用了输入? [英] (Protractor) Checking whether an input is disabled on click?

查看:89
本文介绍了(量角器)检查单击时是否禁用了输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个输入字段,用户名和密码,以及一个微调按钮.当我单击此微调按钮时,这两个输入字段被禁用,我被重定向到另一个页面.我正在编写一个端到端测试,以检查这些输入字段是否被禁用.

I have two input fields, Username and Password and a spinner button. When i click on this spinner button these two input fields get disabled and I am redirected to another page. I am writing an end-to-end testing to check whether these input fields are disabled.

element(by.model('username')).sendKeys('rabi');                   
element(by.model('password')).sendKeys('rabi');                   

/* click on spin button */
spinBtn = element(by.className('call-to-action'));                               
spinBtn.click(); 

/* check if input is disabled */
var loginInput = element(by.id('login-username'));                               
expect(loginInput.isEnabled()).toBe(false);

推荐答案

上一个示例

expect(loginInput.getAttribute('disabled')).toEqual('disabled');

将无法检查是否启用了某些功能.

Will not work for checking if something is enabled.

您应该使用

expect(loginInput.isEnabled()).toBe([true|false]);

准确验证是否已启用/禁用某些功能.

to accurately verify if something is enabled/disabled.

如果这对您不起作用,则可能还有其他情况发生.

If that isn't working for you, there's probably something else going on.

这篇关于(量角器)检查单击时是否禁用了输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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