2014-02-23 4 views
0

저는 SauceLabs로 e2e 테스트를 위해 인턴 또는 분도기를 사용할 것인지 결정하려고하고 있는데 분지기가 제공하는 (by.model, by.binding, by.repeater) 정말 도움이되는 점을 발견했습니다. 그러한 로케이터 전략이 인턴에서 사용할 수 있는지 궁금합니다.인턴은 angularjs 선택기 a-la-protractor를 지원합니까?

답변

2

각도기는 WD.js 라이브러리가 아닌 WebDriverJS 라이브러리를 사용하므로 직접 호환 될 가능성이 없지만 Protractor가 작동하는 방법에 대한 아이디어는 동일한 종류의 도우미 함수를 작성하여 인턴에서 가능할 수 있습니다 그 각도기는 다음과 같은 기능을 제공합니다

function model(modelId) { 
    return this.execute(function() { 
    return document.querySelectorAll(['ng-model=' + modelId + ']'); 
    }); 
} 

편집 : 당신은 또한 사용할 수 있습니다 각도기의, 위의, locators.by.model는 방법 같은 것입니다

define([ 'intern!tdd', 'tests/support/locators' ], function (tdd, locators) { 
    tdd.suite('suite', function() { 
    tdd.test('test', function() { 
     var remote = this.remote; 
     remote.get('http://example.com') 
     .then(locators.by.model('foo')) 
     .then(function (model) {}) 
     // ...etc 
     ; 
    }); 
    }); 

모듈 직접 :

define([ 'intern!tdd', 'intern/dojo/node!protractor/lib/clientsidescripts' ], function (tdd, scripts) { 
    tdd.suite('suite', function() { 
    tdd.test('test', function() { 
     var remote = this.remote; 
     remote.get('http://example.com') 
     .execute(scripts.findByModel, [ 'foo' ]) 
     .then(function (model) {}) 
     // ...etc 
     ; 
    }); 
    }); 
+1

그렇다면 인텐틴을 사용하는 이유는 무엇입니까? –

+0

인턴이 제공하는 [다른 기능] (https://github.com/theintern/intern#comparison) 때문에 : AMD 테스트 모듈, 약속, 다른 테스트 인터페이스, 다른 리포터, 더 나은 구성 요소 통합을 사용하는 비동기 등등. –

+1

Protractor는 클라이언트 측 스크립트를 사용하여 DOM의 요소를 개별 모듈로 가져 오므로 해당 함수를 직접'execute'에 전달할 수 있습니다. 위의 답변을 추가 정보로 업데이트했습니다. –