Flying Cat Penguin

ゆるゆる仕事、ソフトウェアテスティング関連のことについて綴ります。

windows10環境でTestCafeを入れてみる

ちなみに…testcafeがうまく入っていない状態だった。
実行コマンド実行できない感じ…。
グローバルオプションでのインストールでようやく入れられた。

実行コマンド

>npm install -g testcafe
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
C:\Users\odan-tomohiro\AppData\Roaming\npm\testcafe -> C:\Users\odan-tomohiro\AppData\Roaming\npm\node_modules\testcafe\bin\testcafe-with-v8-flag-filter.js
+ testcafe@1.13.0
added 542 packages from 346 contributors in 30.203s


サンプルコード:googleSearchTest.ts

import "testcafe";
import {Selector} from "testcafe";

fixture("Google Search")
    .page("https://www.google.com/");

test("Google Search Test", async (t) => {
    const googleSearchTextArea = Selector(".gLFyf").withAttribute("title", "検索");
    const googleSearchButton   = Selector(".gNO89b").withAttribute("value", "Google 検索");

    await t.typeText(googleSearchTextArea, "TestCafe");
    await t.click(googleSearchButton);
});

出力例

C:\work\testcafework>testcafe chrome googleSearchTest.ts
 Running tests in:
 - Chrome 89.0.4389.114 / Windows 10

 Google Search
 √ Google Search Test


 1 passed (8s)

ひとまずここまで。

参考
tech.pjin.jp