SauceLabs での e2e テストにインターンまたは分度器のどちらを使用するかを決定しようとしています。分度器が提供するこれらの「by」(by.model、by.binding、by.repeater) が非常に役立つことがわかりました。このようなロケーター戦略は、インターンでも使用できます。
1 に答える
2
Protractor は WD.js ライブラリではなく WebDriverJS ライブラリを使用するため、直接互換性がある可能性は低いですが、Protractor が提供するのと同じ種類のヘルパー関数を作成することで、Intern で 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
;
});
});
于 2014-02-25T15:46:54.660 に答える