2017-08-24 123 views
1

对于量角器E2E测试,我很新,想知道元件是否可点击(ExpectedConditions.elementToBeClickable)但不一定可见(ExpectedConditions.visibilityOf)。可点击但不可见?

例如,我有以下代码:

var EC = protractor.ExpectedConditions; 
    var tryItButtonClickable = EC.elementToBeClickable(tryItButton); 
    var tryItButtonVisible = EC.visibilityOf(tryItButton); 

    return browser.wait(EC.and(tryItButtonClickable, tryItButtonVisible), getWaitTime()) 
     .then(function() { 
      var protocol = url.parse(myarray[0].url).protocol; 
       if (protocol === null) { 
        throw new Error('expected ' + protocol + ' not to be null'); 
       } 
     }) 

添加tryItButtonVisible片之前,我就从量角器收到超时错误,大概是因为我的tryItButton是点击,但尚未加载到DOM。

这是真的,还是我是多余的?

感谢

回答

0

这是量角器的官方点击功能

elementToBeClickable(elementFinder: ElementFinder): Function { 
return this.and(this.visibilityOf(elementFinder),() => { 
    return elementFinder.isEnabled().then(passBoolean, falseIfMissing); 
}) 

正如你看到的,它首先检查元素知名度所以答案是NO

资源:https://github.com/angular/protractor/blob/master/lib/expectedConditions.ts线:188

+0

我我只是好奇,至于为什么当我和'两者在一起时,行为就是预期的行为,而当我只使用'elementToBeClickable'时,我的UI会冻结并且可以找不到元素 –

相关问题