ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

Javascript+webdriverio实现app自动化demo

2022-06-24 15:01:27  阅读:52  来源: 互联网

标签:vidma demo app Javascript client sleep editor videomaker id


1.新建工程和安装库

使用WebStorm新建一个空项目然后在编辑器打开终端输入如下命令:

npm init -y npm install webdriverio npm install sleep   2.编写代码 代码如下:
// javascript
const webdriver = require("webdriverio");
const sleep = require("sleep");
const caps = {
    path: '/wd/hub',
    port: 4723,
    capabilities: {
        fullreset: false,
        platformName: "android",
        uiautomator2ServerInstallTimeout: 100000,
        platformVersion: "10",
        deviceName: "Galaxy A11",
        automationName: "UiAutomator2",
        newCommandTimeout: 1000,
        appActivity: "com.atlasv.android.mvmaker.mveditor.SplashActivity",
        appPackage: "vidma.video.editor.videomaker",
        autoGrantPermissions: false,
        noReset: true
    }
};


async function main() {
    const client = await webdriver.remote(caps);
    sleep.sleep(5);
    await client.$("id=vidma.video.editor.videomaker:id/ivAdd").click()
    sleep.sleep(3);
    await client.$$("id=vidma.video.editor.videomaker:id/ivIcon")[1].click();
    sleep.sleep(3);
    await client.$("id=vidma.video.editor.videomaker:id/tvNext").click();
    sleep.sleep(3);
    await client.$("id=vidma.video.editor.videomaker:id/ivBack").click();
    client.closeApp();
}

main().then(() => console.log("执行完成!"));

标签:vidma,demo,app,Javascript,client,sleep,editor,videomaker,id
来源: https://www.cnblogs.com/wanyuan/p/16408864.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有