2014-12-24 2 views
0

페이지로드시 특정 ng-model이 정의되지 않았는지 확인하려고합니다. 그러나 ng-model을 정의하는 div은이 테스트에서 false로 평가되는 ng-if 문을 사용하며 각도기가 지정된 바인딩을 가진 요소를 찾을 수없는 것 같습니다. 보기 코드를 변경하지 않고 내 모델 값을 확인하는 방법이 있습니까?각도기에서 바인딩의 값이 정의되지 않았다고 주장하는 방법은 무엇입니까?

현재 내 테스트는 다음과 같습니다

describe('loading the create invoice page for the first time', function() { 

    it('should have an undefined invoice.messages value', function() { 

     browser.get('http://persianturtle.com/app/#/invoice/create'); 

     expect(element(by.binding('invoice.messages'))).toBe(undefined); 

    }); 
}); 

그리고 테스트의 결과 : 당신은 isPresent()을 사용할 수 있습니다

NoSuchElementError: No element found using locator: by.binding("invoice.messages")

답변

4

:

expect(element(by.binding('invoice.messages')).isPresent()).toBeFalsy(); 

Here is the Protractor documentationisPresent() 위해.

그러나 binding 대신 DOM id 또는 css를 선택해야 할 수 있습니다

expect(element(by.id('#id-in-the-dom-for-invoice-messages')).isPresent()).toBeFalsy(); 
expect(element(by.css('.class-in-the-dom-for-invoice-messages')).isPresent()).toBeFalsy(); 
+0

감사합니다! 이것은 내가 찾고 있었던 바로 그 것이다. –

관련 문제