Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Disabled不被视为HTML属性_Javascript_Html_Angular_Testing_Chai - Fatal编程技术网

Javascript Disabled不被视为HTML属性

Javascript Disabled不被视为HTML属性,javascript,html,angular,testing,chai,Javascript,Html,Angular,Testing,Chai,我有这个html按钮 constdom=newjsdom(` `) 我对Chai不太了解,但我刚刚了解了它,请尝试下面的一个 prop() or property() dom.window.document.getElementById("ref_button").should.have.prop('disabled'); 或 更新的代码片段 你能试试下面的吗 is() dom.window.document.getElementById("ref_button").is('[disab

我有这个html按钮

constdom=newjsdom(`
`)

我对Chai不太了解,但我刚刚了解了它,请尝试下面的一个

prop() or property()

dom.window.document.getElementById("ref_button").should.have.prop('disabled');

更新的代码片段

你能试试下面的吗

is()

dom.window.document.getElementById("ref_button").is('[disabled]')).toBe(true)
以上一种可能有效,请尝试一下。如果没有,请尝试下面的一个

hasAttr() or hasAttribute()

dom.window.document.getElementById("ref_button").hasAttribute('disabled')

但是如果我想用与中相同的方法进行测试,我编辑了这个问题,结果是一样的,可能你需要参考chai doc,因为我认为你使用的是Jasmine。这些方法在chaiOh中不存在,因为它适用于anotehr属性,这意味着这是正确的方法!但是,当该属性值为null且为true时,对于表单中的数据输入,它可能无法识别该属性值中的vRange。@Tester:-)是的,我只是指Chai文档。我一直在让你知道我从那里了解到了什么。你是说它对另一个属性有效。。。!!!我的回答中有哪句话对你有用吗?一年前,我使用量角器编写测试用例,现在我完全进入了开发阶段:-)不,如果你读了我的问题,我说我所做的工作适用于anotehr属性。但是你的代码更像Jasmine
hasAttr() or hasAttribute()

dom.window.document.getElementById("ref_button").hasAttribute('disabled')