2016-01-29 46 views

回答

3

呀,测试不可见可苏茨基。您应该可以使用isPresent(),这意味着在dom中,其中isDisplayed()意味着它实际上可见,我认为这是您的问题。尝试...

expect(element(CastModule.PersonXpath).isPresent()).toEqual(false); 

您可能还想将其分解为方法并使用Expected Condition

+0

很酷,谢谢。例如,如果我检查“x”分钟后元素不再显示,我需要使用什么? – user3188198

0

我设法找到了一个解决方案,使用量角器库。

var EC = protractor.ExpectedConditions;  browser.wait(EC.invisibilityOf(element(by.xpath(CastModule.PersonXpath))), 5000).then(function() { 
      if (EC.invisibilityOf(element(by.xpath(x.LanguagesXpath)))) { 
       console.log("Persons module is not present - as expected for this scenario"); 
      } else { 
       throw new Error("Element STILL present"); 
      } 
     }); 
    }); 
1

要检查的知名度(如果isDisplayedisPresent不工作),只需使用:

if (!EC.invisibilityOf(ug.personXpath)) { 
    throw new Error("Partner logo is not displayed"); 
} 
1

的错误看起来并不像它与正在显示的元素做。它看起来像是与页面同步。试着忽略了同步,然后等待角以上的预计有:

browser.ignoreSynchronization = true; 
browser.waitForAngular(); 
expect(element(CastModule.PersonXpath).isDisplayed()).toEqual(false); 
-1

要使用元素的使用存在:

var elm = element(CastModule.PersonXpath); 
       elm.isPresent().then(function (present) { 
        if (present) { 
         element(CastModule.PersonXpath).then(function (labels) { 

         }); 

        } else { 
         console.log('Element did not found'); 

        }`enter code here` 
相关问题