Appuim で Android のスクリーンキャプチャーを取るには?
index.js
const driver = require("webdriverio"); const assert = require("assert"); const opts = { path: '/wd/hub', port: 4723, capabilities: { platformName: "Android", platformVersion: "12", deviceName: "Android Emulator", app: "/Users/falco/Downloads/ApiDemos-debug.apk", appPackage: "io.appium.android.apis", appActivity: ".view.TextFields", automationName: "UiAutomator2" } }; async function main () { const client = await driver.remote(opts); await pauseSec(5) // Screen shot を取る client.saveScreenshot("first.png"); const field = await client.$("android.widget.EditText"); await field.setValue("Hello World!"); await pauseSec(5) await field.setValue("Hello World!!!!!!"); const value = await field.getText(); assert.strictEqual(value,"Hello World!"); await pauseSec(5) await client.deleteSession(); } async function pauseSec(timeSec) { console.log("Start pauseSec") await new Promise(r => setTimeout(r, timeSec * 1000)); console.log("End") } main();
node index.js
デモ用アプリ
https://github.com/appium/appium/raw/master/sample-code/apps/ApiDemos-debug.apk