0

我有以下问题:

  • 我有一个页面,只有当我在文本字段中输入某个值时,“保存按钮”才会变为可点击。
  • 我要做的是检查是否禁用了保存按钮,然后我需要在该文本字段中输入一些值。

我的想法是有这样的东西:

if (save button is disabled){
   enter text inside the filed
   click save button
}

我不能做的是将被禁用的保存按钮的值存储到布尔变量中。

谢谢!

4

2 回答 2

0

您可以getAttribute()按照他的方式使用:

var yourElement = element(by.id('foo')); //find by id, class or whatever you want
expect(yourElement.getAttribute('disabled')).toBe(true)

文档在这里

所以为了你的目的,你可以使用这样的东西:

if (yourElement.getAttribute('disabled')){
   enter text inside the filed
   click save button
}
于 2020-11-27T09:20:45.577 回答
0

感谢您的解决方案!

我是这样写的:

        assertDisabled = function(){
            assertionsPage.assertAttribute(myProfilePage.saveButton,'disabled','true')
            return true
        }
        var value = assertDisabled()
        console.log(value)
        if (value==true){
            myProfilePage.pinCodeValue.sendKeys(1234)
        }

assertAttribute 完全按照您所说的进行,但我认为它可以用于其他测试。

于 2020-11-27T10:45:28.690 回答