Javascript Disabled不被视为HTML属性
我有这个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
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')