Expect API
概要
Nightwatchは、メインのNightwatchインスタンスのexpect
名前空間で定義された要素に対するアサーションを実行するための、流暢な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;
});
}