2014-03-05 3 views
2

각도기를 사용하여 새로운 오전, 일부 e2e 테스트를 실행하고 드롭 다운 목록을 호출하고 해당 옵션 중 하나를 선택할 때이 마지막 한 문제가 있습니다.각도기 드롭 다운 목록 요소 e2e 테스트

document is not defined 

방법 오류 가능성이 있습니다 :

it('filter', function() { 
    console.log('test log'); 

    var e = document.getElementById('Develop'); 
    var strUser = e.options[e.selectedIndex].value; 

    e.selectedIndex = 2; 
}); 

내가 때마다 얻는 referenceError은 다음과 같습니다

이 내 코드?

미리 도움을 주셔서 감사합니다.

답변

0

는 또한 E2E 테스트 일하고, 나는 드롭 다운 옵션을 선택하기 위해 여러 가지 기능을 가지고 :

이 값 드롭 다운을 선택합니다.

this.selectDropdownByLabel = function (dropdownElement, label) { 
     return this.selectDropdownByAttribute(dropdownElement, 'label', label); 
    }; 

:

this.selectDropdownByPartialLabel = function (dropdownElement, partialLabel) { 
     return this.selectDropdownByAttribute(dropdownElement, 'label', partialLabel, true); 
}; 

가 레이블로 드롭 다운을 선택

this.selectDropdownByIndex = function (dropdownElement, index) { 
     dropdownElement.click(); 
     dropdownElement.all(by.css('option')).get(index).click(); 
}; 

아래 부분 라벨에 의해 드롭을 선택

this.selectDropdownByValue = function (dropdownElement, value) { 
     return this.selectDropdownByAttribute(dropdownElement, 'value', value); 
}; 

인덱스에 의해 드롭 다운 선택 그리고 내부에서 사용되는 기능 각 드롭 다운 기능은 다음과 같습니다.

this.selectDropdownByAttribute = function (dropdownElement, attribute, value, partial, index) { 
     var pathModifier = ''; 

     if (typeof index === 'undefined') { 
      index = 0; 
     } 

     if (typeof partial === 'undefined') { 
      partial = false; 
     } 

     if (partial) { 
      pathModifier = '*'; 
     } 

     dropdownElement.click().then(function() { 
      dropdownElement.all(by.css('option[' + attribute + pathModifier + '="' + value + '"]')).get(index).click(); 
     }); 
    }; 

이 정보가 도움이되기를 바랍니다. 드롭 다운과 상호 작용 할 때

0

나는 같은 문제를 가로 질러 와서 나는 나를 내가 원하는 정확한 드롭 다운 요소를

요소 (by.model ('Model.name')를 선택 도움이되었습니다이 형식을 사용하여 관리) .click(). 요소 (By.xpath ('Xpath')). click();

기본적으로 드롭 다운의 위치를 ​​클릭하고 클릭 한 다음 해당 xpath를 통해 드롭 다운 요소를 찾은 다음 한 줄에 분리하지 않습니다.

희망이 도움이되었습니다.

관련 문제