Expect API
概要
Nightwatchは、メインのNightwatchインスタンスのexpect
名前空間で定義された、要素に対するアサーションを実行するためのfluentなBDDスタイルのインターフェースを提供します。これは、Chai Expectアサーションライブラリに基づいており、より高い柔軟性を提供するとともに、従来からのassert
インターフェースに対して新たな機能を追加しています。
これは、CSS/XPathセレクターで指定された要素に対してアサーションを構成するための、チェーン可能な言語を使用します。簡単な例は次のようになります。
javascript
describe('expect example', function() {
it('sample test', function (browser) {
// start with identifying the element
// and then assert the element is present
browser.expect.element('#main').to.be.present;
// or assert the element is visible
browser.expect.element('#main').to.be.visible;
});
}