私はMochaとChaiでwebdriver-ioを初めて使用しています。まず第一に、ここでは私のスクリプトです:少数のWebdriver IO Mocha Chaiの質問
var homePage = 'http://www.mypage.com';
var expect = require("chai").expect;
var headerText = 'h1.browse-header-title';
var currentHeaderText;
var links = ['Furniture','Fine Art','Jewelry & Watches','Fashion'];
describe('Test Suite 1', function(){
before(function(){
console.log('Running navigation h1 tag suite');
});
afterEach(function(){
browser.close();
// What method do I use?
});
it('Should click Furniture and page header should match', function(done){
browser.url(homePage).click('a[data-tn="global-nav-item-link-furniture"]');
currentHeaderText = browser.getText(headerText);
expect(currentHeaderText).to.equal(links[0]);
console.log('h1 tag is '+currentHeaderText+'');
});
it('Should click Fine Art and page header should match', function(done){
browser.url(homePage).click('a[data-tn="global-nav-item-link-fine-art"]');
currentHeaderText = browser.getText(headerText);
expect(currentHeaderText).to.equal(links[1]);
console.log('h1 tag is '+currentHeaderText+'');
});
it('Should click Jewelry & Watches and page header should match', function(done){
browser.url(homePage).click('a[data-tn="global-nav-item-link-jewelry-&-watches"]');
currentHeaderText = browser.getText(headerText);
expect(currentHeaderText).to.equal(links[2]);
console.log('h1 tag is '+currentHeaderText+'');
});
it('Should click Fashion and page header should match', function(done){
browser.url(homePage).click('a[data-tn="global-nav-item-link-fashion"]');
currentHeaderText = browser.getText(headerText);
expect(currentHeaderText).to.equal(links[3]);
console.log('h1 tag is '+currentHeaderText+'');
});
});
私の最初の質問は、それらを呼び出すための変数と、適切な方法を格納するためのより良い場所はありますか?
afterEach browser.close()関数を実行しているときに、ブラウザセッションをリセットする最良の方法は何ですか?browser.reset()を試しましたが、2番目のテストを呼び出すと正常に動作しませんでした。 mochaとchaiの方がブラウザを閉じ、セッションをリセットしてブラウザを開いてホームページに行くより良い方法はありますか?
1)試験はチャイを使用してアサーションとモカに書かれている必要があります
これらは私が与えられた要件でした。テストを実行するために使用される フレームワークはwebdriverIOでなければなりません。ネイティブのセレンコマンドはありません。
2)試験は、おそらくそのようなユーザ メール/パスワードのような他の試験()で使用される変数は別に保存されるべきである)ページオブジェクトパターン
3を利用するように書かなければなりませんテストファイル