2014-10-29 11 views
1

각도기에 대해 더 자세히 알고 싶습니다. 질문 : 요소가 페이지에 존재하는지 어떻게 확인합니까? firstNsame이라는 첫 번째 속성이 없습니다. 요소가 존재하지 않으면 나머지 스크립트로 넘어 가고 싶습니다. 나는이 스크립트를 사용하지만, isPresent() 코드가 작동하지 않는 모양입니다 :요소가 존재하는지 여부를 어떻게 확인할 수 있습니까?

var data = {"firstNsame": "Joke", "lastName": "Moker", "stateId": 49}; 

for (var key in data) { 
    try { 
     if (data.hasOwnProperty(key)) { 
      var el = element(by.model(key)); 
      if (el.isPresent()) 
      { 
       console.log('element present',key); 
      } 
      else 
      { 
       console.log('element not present',key); 
      } 

     } 
    } 
    catch (err) { 
     console.log('error occured',err); 
    } 
} 
+1

각도기 테스트는 약속을 반환합니다. – Pindakaas

답변

1

는 다음과 같은 시도 : 하나를 구성해야합니다 있도록

element(by.model(key)).isPresent().then(function(present) { 
    console.log('Element present', present) 
}); 
관련 문제