私の目標は、knockoutJSページ(ページ上にAngularJSは全くありません)でe2eテストを実行することです。私はこのテストに分度器を使い始めました。 browser.ignoreSynchronization=true
と約束を多用した場合、仕様は正しい順序で実行されているように見えますが、expect
のステートメントが見つかったようです。私はメッセージNo specs found
を受け取ったにもかかわらず、expect
の文を内部に持つit
コールが3つあります。KnockoutJSを使った分度器
PS C:\> protractor conf.js
[09:38:08] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[09:38:08] I/launcher - Running 1 instances of WebDriver
load the page in the browser. use promises to keep the flow of the tests accurate
Started
No specs found
Finished in 0 seconds
wait for the form to load (check presence of specific input
change select to specific option in order to show additional content on the page
wait for addtional fields to load completely
test that the additional field is present.
update the source field with the test value
Test that the targetField has the highlight class.
update the target field with the test value.
Test that the targetField does not have the hightlight class.
[09:38:13] I/launcher - 0 instance(s) of WebDriver still running
[09:38:13] I/launcher - chrome #01 passed
私の研究は、使用して分度器がAngularJSのために提唱されていることを示している:私は次の出力を得る
var debug = true;
describe('check for highlighting', function() {
var url = 'http://domain/page.aspx',
formLoadedField = 'NameField',
selectId = 'Action',
selectValue = 'Change Values Option',
testValue = 'Some Test Value!!',
sourceField = 'FromField',
targetField = 'ToField',
EC = protractor.ExpectedConditions;
browser.ignoreSynchronization = true;
log('load the page in the browser. use promises to keep the flow of the tests accurate');
browser.get(url)
.then(function(){
log('wait for the form to load (check presence of specific input)');
browser.wait(EC.presenceOf(element(by.id(formLoadedField))), 5 * 1000);
log('change select to specific option in order to show additional content on the page');
element(by.cssContainingText('#'+selectId+' option', selectValue)).click();
})
.then(function(){
log('wait for addtional fields to load completely');
browser.wait(EC.presenceOf(element(by.id(targetField))), 5 * 1000);
})
.then(function(){
log('test that the additional field is present.');
it('should have a targetField element', function() {
expect(EC.presenceOf(element(by.id(targetField)))).toBe(true);
});
})
.then(function(){
log('update the source field with the test value');
element(by.id(sourceField)).sendKeys(testValue);
log('Test that the targetField has the highlight class.');
it('targetField should be highlighted when values are different', function() {
expect(hasClass(element(by.id(targetField)),'highlight')).toBe(true);
});
})
.then(function(){
log('update the target field with the test value.');
element(by.id(targetField)).sendKeys(testValue);
log('Test that the targetField does not have the hightlight class.');
it('targetField should NOT be highlighted when values are equal', function() {
expect(hasClass(element(by.id(targetField)),'highlight')).not.toBe(true);
});
});
});
function log(msg){
if(debug){
console.log(msg);
}
}
:
は、ここに私のコードです。私は は(KnockoutJSページ上のE2Eテストを)しようとしています何のためにジャスミンの代わりに、分度器を使って
- いくつかの提唱者。
- 分度器は でKnockoutJSページのテストには十分だと言われていますが、テストのタイミングは 自分で管理する必要があります(分度器の重要な機能)。
- 私は、テストの前にignoreSynchronizationをtrueに設定してから 、その後にfalseに戻っていましたが、それは私が を探している(または私は戦略を誤解しています)結果を与えませんでした。
- 私は以前にテストを実行することができましたが、非同期 の分度器の性質のため、テストは ページの変更と同期していなかったため、テストは無関係でした。
私はあなたのご意見をお待ちしております。
@ alec.xe入力と方向をありがとうございます。質問:コードを変更すると、各テストに新しいブラウザセッションが必要になります。ページの値が変わるたびに一連のテストが完了するように設定できますか? – Bill
@Billよく、きれいなブラウザセッションで各テストを開始し、 'beforeEach'または' beforeAll'の中をナビゲートするのが一般的なパターンです。http://stackoverflow.com/questions/25740056/keep- protractor-browser-session-alive ..thanksです。 – alecxe
@ alec.xeありがとう! – Bill