0
我想決定是否使用實習生或量角器爲我的e2e測試與SauceLabs,我發現真正有用的這些「由」量角器提供(by.model,by.binding,by.repeater),我是想知道這樣的定位策略是否也可以在實習中使用。實習生是否支持angularjs選擇器a-la量角器?
我想決定是否使用實習生或量角器爲我的e2e測試與SauceLabs,我發現真正有用的這些「由」量角器提供(by.model,by.binding,by.repeater),我是想知道這樣的定位策略是否也可以在實習中使用。實習生是否支持angularjs選擇器a-la量角器?
量角器使用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
;
});
});
因此,鑑於爲什麼使用實習生比量角器的任何理由? –
由於所有[其他功能](https://github.com/theintern/intern#comparison)實習生提供的量角器不包括:AMD測試模塊,異步使用承諾,不同的測試接口,不同的記者,更好的組件集成等等。 –
事實證明,Protractor公開了它用來從DOM中將元素作爲一個獨立模塊提取的客戶端腳本,所以你可以直接將這些函數傳遞給'execute'。我已經用更多的信息更新了上面的答案。 –