LoginSignup
4
3

More than 5 years have passed since last update.

WebdriverIOメモ

Posted at

WebdriverIOを使うときのメモ

業務でWEBテストをする必要があったので、その時のメモ
本家サイトAPIDOCが充実しているので、英語に免疫のある人はそっち見たほうが良い。

作業環境

ツール バージョン
WebdriverIO 4.8.0
node.js 6.10.3
npm 3.10.10
selenium-server-standalone 3.5.3

実際の構築は別の誰かに任せます。

Tips

URLへアクセス

sample.js
browser.url(weburl);

いろいろ取得

sample.js
// ブラウザのタイトル
browser.getTitle()
// 指定したセレクタ内のテキスト
browser.getText(selector);
// 指定したセレクタのAttribute
browser.getAttribute(selector,attributeName);

動作させる

sample.js
// クリック
browser.click(selector);
// input:type=text要素に値を設定
browser.setValue(selector,text);
// セレクトボックスの操作
$(selector).selectByIndex(number)

フレーム間の移動

sample.js
// フレームへ移動
browser.waitForExist(selector);
browser.frame($(selector).value);
// 親フレームへ戻る
browser.frameParent();

スクリーンショットの取得

sample.js
// 指定したファイル名の個所(カレントからの相対)に保存される
browser.saveScreenshot('ファイル名');

// こうするとスクリーンショットをBASE64で取得できる
const screenshot = browser.screenshot();
4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3