メインコンテンツにスキップ

便利な期待条件ライブラリサービス

wdio-wait-forは、サードパーティのパッケージです。詳細についてはGitHub | npmをご覧ください。

wdio-wait-forはWebdriverIO向けのNode.jsライブラリで、定義されたタスクが完了するまで特定の条件を待機するための機能を提供する一般的な条件セットを提供します。

Installation

プロジェクトでwdio-wait-forを使用するには、次のコマンドを実行します:

npm i -D wdio-wait-for

Yarnを使用している場合は、次のコマンドを実行します:

yarn add --dev wdio-wait-for

API

Examples

Import

CommonJS

WebdriverIO v7以下とCommonJSを使用している場合は、requireを使用してパッケージをインポートする必要があります:

// import all methods
const EC = require('wdio-wait-for');

browser.waitUntil(EC.alertIsPresent(), { timeout: 5000, timeoutMsg: 'Failed, after waiting for the alert to be present' })
// import specific method
const { alertIsPresent } = require('wdio-wait-for');

browser.waitUntil(alertIsPresent(), { timeout: 5000, timeoutMsg: 'Failed, after waiting for the alert to be present' })

ESM

TypeScriptまたはWebdriverIO v8以上では、import文を使用してすべてのヘルパーメソッドをインポートできます:

// import all methods
import * as EC from 'wdio-wait-for';

browser.waitUntil(EC.elementToBeEnabled('input'), { timeout: 5000, timeoutMsg: 'Failed, after waiting for the element to be enabled' })

または特定のメソッドだけをインポートすることもできます:

// import specific method
import { elementToBeEnabled } from 'wdio-wait-for';

browser.waitUntil(elementToBeEnabled('input'), { timeout: 5000, timeoutMsg: 'Failed, after waiting for the element to be enabled' })

Wait for alert

このコードスニペットは条件の使い方を示しています

browser.waitUntil(alertIsPresent(), { timeout: 5000, timeoutMsg: 'Failed, after waiting for the alert to be present' })

Wait for Elements

このコードスニペットは、特定の数の要素が存在するのを待つなどの条件の使い方を示しています:

browser.waitUntil(numberOfElementsToBe('.links', 2), { timeout: 5000, timeoutMsg: 'Failed, after waiting for the 2 elements' })

License

MIT licensed.

Author

Yevhen Laichenkov - elaichenkov@gmail.com
Christian Bromann - mail@bromann.dev

Welcome! How can I help?

WebdriverIO AI Copilot