2014-02-23 25 views

回答

2

量角器使用WebDriverJS庫,而不是WD.js庫,所以它不可能直接兼容,但通過編寫相同類型的輔助函數,實際上Protractor的工作原理也是可能的該量角器規定:

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 
     ; 
    }); 
    }); 

其中,在上面,locators.by.model是一個方法,如:

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

編輯:您還可以用量角器的clientsidescripts模塊直接:

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'。我已經用更多的信息更新了上面的答案。 –