• 8.Appium的基本使用-1


    1.Appium是什么?
    Appium是一个跨平台移动端自动化测试工具,可以便捷的为ios和Android平台创建自动化测试用例。
    模拟app内部各种操作,点击、滑动、文本输入等,手工操作的动作appium都能完成。
    ios设备:appium使用UIAutomation实现驱动
    Android设备:使用UIAutomator和Selendroid来实现驱动。

    2.启动Appium,监听4723端口。

    3.配置Android手机通过数据线和运行的Appium的PC相连,打开手机端USB调试功能确保可以连接到手机。

    adb在上一节已经配置安装完成(参照上一节)。

    cmd输入adb命令测试连接情况:  adb devices -l  (连接成功如下图所示,我用的是小米5x)

    这里获取的连接信息配置要用到。

     4.Appium内置驱动打开App,点击Appium 中搜索符号,如图进入配置界面配置Desired Capabilities 参数 

     platformName:平台名称

     deviceName:设备名称

     appPackage:app程序包名

     appActivity:入口Activity名,通常以.开头

    5.点击保存

    6.点击 start session,就可以启动Android 手机上的微信app并进入启动页面,但是我这里出现了一个问题报了一个错误。

    appium界面情况:
    [Appium] Welcome to Appium v1.9.1
    [Appium] Appium REST http interface listener started on 0.0.0.0:4723
    [HTTP] --> GET /wd/hub/sessions
    [HTTP] {}
    [GENERIC] Calling AppiumDriver.getSessions() with args: []
    [GENERIC] Responding to client with driver.getSessions() result: []
    [HTTP] <-- GET /wd/hub/sessions 200 11 ms - 40
    [HTTP] 
    [HTTP] --> GET /wd/hub/sessions
    [HTTP] {}
    [GENERIC] Calling AppiumDriver.getSessions() with args: []
    [GENERIC] Responding to client with driver.getSessions() result: []
    [HTTP] <-- GET /wd/hub/sessions 200 3 ms - 40
    [HTTP] 
    [HTTP] --> POST /wd/hub/session
    [HTTP] {"desiredCapabilities":{"appActivity":".ui.LauncherUI","appPackage":"com.tencent.mm","deviceName":"MI_5X","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true}}
    [MJSONWP] Calling AppiumDriver.createSession() with args: [{"appActivity":".ui.LauncherUI","appPackage":"com.tencent.mm","deviceName":"MI_5X","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null]
    [BaseDriver] Event 'newSessionRequested' logged at 1541407442906 (16:44:02 GMT+0800 (中国标准时间))
    [Appium] Creating new AndroidDriver (v4.1.1) session
    [Appium] Capabilities:
    [Appium]   appActivity: .ui.LauncherUI
    [Appium]   appPackage: com.tencent.mm
    [Appium]   deviceName: MI_5X
    [Appium]   platformName: Android
    [Appium]   newCommandTimeout: 0
    [Appium]   connectHardwareKeyboard: true
    [BaseDriver] Creating session with MJSONWP desired capabilities: {"appActivity":".ui.Launche...
    [BaseDriver] The following capabilities were provided, but are not recognized by appium: connectHardwareKeyboard.
    [BaseDriver] Session created with session id: 1ec2b612-50a3-4a7c-b830-6cdd026cf0e4
    [AndroidDriver] Shutting down Android driver
    [AndroidDriver] Called deleteSession but bootstrap wasn't active
    [BaseDriver] Event 'newSessionStarted' logged at 1541407443065 (16:44:03 GMT+0800 (中国标准时间))
    [MJSONWP] Encountered internal error running command: Error: Command 'java' not found. Is it installed?
    [MJSONWP]     at ChildProcess. (C:Usersvm510AppDataLocalProgramsAppium
    esourcesapp
    ode_modulesappium
    ode_modules	een_processlibexec.js:39:14)
    [MJSONWP]     at ChildProcess.emit (events.js:182:13)
    [MJSONWP]     at Process.ChildProcess._handle.onexit (internal/child_process.js:235:12)
    [MJSONWP]     at onErrorNT (internal/child_process.js:406:16)
    [MJSONWP]     at process._tickCallback (internal/process/next_tick.js:63:19)
    [HTTP] <-- POST /wd/hub/session 500 164 ms - 179
    [HTTP] 
    [HTTP] --> DELETE /wd/hub/session
    [HTTP] {}
    [HTTP] No route found. Setting content type to 'text/plain'
    [HTTP] <-- DELETE /wd/hub/session 404 8 ms - 57
    [HTTP] 
    [HTTP] --> POST /wd/hub/session
    [HTTP] {"desiredCapabilities":{"appActivity":".ui.LauncherUI","appPackage":"com.tencent.mm","deviceName":"MI_5X","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true}}
    [MJSONWP] Calling AppiumDriver.createSession() with args: [{"appActivity":".ui.LauncherUI","appPackage":"com.tencent.mm","deviceName":"MI_5X","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null]
    [BaseDriver] Event 'newSessionRequested' logged at 1541407449259 (16:44:09 GMT+0800 (中国标准时间))
    [Appium] Creating new AndroidDriver (v4.1.1) session
    [Appium] Capabilities:
    [Appium]   appActivity: .ui.LauncherUI
    [Appium]   appPackage: com.tencent.mm
    [Appium]   deviceName: MI_5X
    [Appium]   platformName: Android
    [Appium]   newCommandTimeout: 0
    [Appium]   connectHardwareKeyboard: true
    [BaseDriver] Creating session with MJSONWP desired capabilities: {"appActivity":".ui.Launche...
    [BaseDriver] The following capabilities were provided, but are not recognized by appium: connectHardwareKeyboard.
    [BaseDriver] Session created with session id: aad85d91-1bb2-465e-8e3c-e0cd1a4c12c4
    [AndroidDriver] Shutting down Android driver
    [AndroidDriver] Called deleteSession but bootstrap wasn't active
    [BaseDriver] Event 'newSessionStarted' logged at 1541407449271 (16:44:09 GMT+0800 (中国标准时间))
    [MJSONWP] Encountered internal error running command: Error: Command 'java' not found. Is it installed?
    [MJSONWP]     at ChildProcess. (C:Usersvm510AppDataLocalProgramsAppium
    esourcesapp
    ode_modulesappium
    ode_modules	een_processlibexec.js:39:14)
    [MJSONWP]     at ChildProcess.emit (events.js:182:13)
    [MJSONWP]     at Process.ChildProcess._handle.onexit (internal/child_process.js:235:12)
    [MJSONWP]     at onErrorNT (internal/child_process.js:406:16)
    [MJSONWP]     at process._tickCallback (internal/process/next_tick.js:63:19)
    [HTTP] <-- POST /wd/hub/session 500 16 ms - 179
    [HTTP] 
    [HTTP] --> DELETE /wd/hub/session
    [HTTP] {}
    [HTTP] No route found. Setting content type to 'text/plain'
    [HTTP] <-- DELETE /wd/hub/session 404 1 ms - 57
    [HTTP] 
    [HTTP] --> POST /wd/hub/session
    [HTTP] {"desiredCapabilities":{"appActivity":".ui.LauncherUI","appPackage":"com.tencent.mm","deviceName":"MI_5X","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true}}
    [MJSONWP] Calling AppiumDriver.createSession() with args: [{"appActivity":".ui.LauncherUI","appPackage":"com.tencent.mm","deviceName":"MI_5X","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null]
    [BaseDriver] Event 'newSessionRequested' logged at 1541407492319 (16:44:52 GMT+0800 (中国标准时间))
    [Appium] Creating new AndroidDriver (v4.1.1) session
    [Appium] Capabilities:
    [Appium]   appActivity: .ui.LauncherUI
    [Appium]   appPackage: com.tencent.mm
    [Appium]   deviceName: MI_5X
    [Appium]   platformName: Android
    [Appium]   newCommandTimeout: 0
    [Appium]   connectHardwareKeyboard: true
    [BaseDriver] Creating session with MJSONWP desired capabilities: {"appActivity":".ui.Launche...
    [BaseDriver] The following capabilities were provided, but are not recognized by appium: connectHardwareKeyboard.
    [BaseDriver] Session created with session id: 1eef1933-beb8-40d3-bf1f-d58fa8b266bf
    [AndroidDriver] Shutting down Android driver
    [AndroidDriver] Called deleteSession but bootstrap wasn't active
    [BaseDriver] Event 'newSessionStarted' logged at 1541407492348 (16:44:52 GMT+0800 (中国标准时间))
    [MJSONWP] Encountered internal error running command: Error: Command 'java' not found. Is it installed?
    [MJSONWP]     at ChildProcess. (C:Usersvm510AppDataLocalProgramsAppium
    esourcesapp
    ode_modulesappium
    ode_modules	een_processlibexec.js:39:14)
    [MJSONWP]     at ChildProcess.emit (events.js:182:13)
    [MJSONWP]     at Process.ChildProcess._handle.onexit (internal/child_process.js:235:12)
    [MJSONWP]     at onErrorNT (internal/child_process.js:406:16)
    [MJSONWP]     at process._tickCallback (internal/process/next_tick.js:63:19)
    [HTTP] <-- POST /wd/hub/session 500 31 ms - 179
    [HTTP] 
    [HTTP] --> DELETE /wd/hub/session
    [HTTP] {}
    [HTTP] No route found. Setting content type to 'text/plain'
    [HTTP] <-- DELETE /wd/hub/session 404 2 ms - 57
    [HTTP] 
    [HTTP] --> POST /wd/hub/session
    [HTTP] {"desiredCapabilities":{"appActivity":".ui.LauncherUI","appPackage":"com.tencent.mm","deviceName":"MI_5X","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true}}
    [MJSONWP] Calling AppiumDriver.createSession() with args: [{"appActivity":".ui.LauncherUI","appPackage":"com.tencent.mm","deviceName":"MI_5X","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null]
    [BaseDriver] Event 'newSessionRequested' logged at 1541407700506 (16:48:20 GMT+0800 (中国标准时间))
    [Appium] Creating new AndroidDriver (v4.1.1) session
    [Appium] Capabilities:
    [Appium]   appActivity: .ui.LauncherUI
    [Appium]   appPackage: com.tencent.mm
    [Appium]   deviceName: MI_5X
    [Appium]   platformName: Android
    [Appium]   newCommandTimeout: 0
    [Appium]   connectHardwareKeyboard: true
    [BaseDriver] Creating session with MJSONWP desired capabilities: {"appActivity":".ui.Launche...
    [BaseDriver] The following capabilities were provided, but are not recognized by appium: connectHardwareKeyboard.
    [BaseDriver] Session created with session id: 7de96b9a-4680-420e-bdee-d8c9619f12b6
    [AndroidDriver] Shutting down Android driver
    [AndroidDriver] Called deleteSession but bootstrap wasn't active
    [BaseDriver] Event 'newSessionStarted' logged at 1541407700532 (16:48:20 GMT+0800 (中国标准时间))
    [MJSONWP] Encountered internal error running command: Error: Command 'java' not found. Is it installed?
    [MJSONWP]     at ChildProcess. (C:Usersvm510AppDataLocalProgramsAppium
    esourcesapp
    ode_modulesappium
    ode_modules	een_processlibexec.js:39:14)
    [MJSONWP]     at ChildProcess.emit (events.js:182:13)
    [MJSONWP]     at Process.ChildProcess._handle.onexit (internal/child_process.js:235:12)
    [MJSONWP]     at onErrorNT (internal/child_process.js:406:16)
    [MJSONWP]     at process._tickCallback (internal/process/next_tick.js:63:19)
    [HTTP] <-- POST /wd/hub/session 500 30 ms - 179
    [HTTP] 
    [HTTP] --> DELETE /wd/hub/session
    [HTTP] {}
    [HTTP] No route found. Setting content type to 'text/plain'
    [HTTP] <-- DELETE /wd/hub/session 404 1 ms - 57
    [HTTP] 
    [HTTP] --> POST /wd/hub/session
    [HTTP] {"desiredCapabilities":{"appActivity":".ui.LauncherUI","appPackage":"com.tencent.mm","deviceName":"MI_5X","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true}}
    [MJSONWP] Calling AppiumDriver.createSession() with args: [{"appActivity":".ui.LauncherUI","appPackage":"com.tencent.mm","deviceName":"MI_5X","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null]
    [BaseDriver] Event 'newSessionRequested' logged at 1541407780059 (16:49:40 GMT+0800 (中国标准时间))
    [Appium] Creating new AndroidDriver (v4.1.1) session
    [Appium] Capabilities:
    [Appium]   appActivity: .ui.LauncherUI
    [Appium]   appPackage: com.tencent.mm
    [Appium]   deviceName: MI_5X
    [Appium]   platformName: Android
    [Appium]   newCommandTimeout: 0
    [Appium]   connectHardwareKeyboard: true
    [BaseDriver] Creating session with MJSONWP desired capabilities: {"appActivity":".ui.Launche...
    [BaseDriver] The following capabilities were provided, but are not recognized by appium: connectHardwareKeyboard.
    [BaseDriver] Session created with session id: a53170dd-299c-4767-81f8-b6999ef40638
    [AndroidDriver] Shutting down Android driver
    [AndroidDriver] Called deleteSession but bootstrap wasn't active
    [BaseDriver] Event 'newSessionStarted' logged at 1541407780083 (16:49:40 GMT+0800 (中国标准时间))
    [MJSONWP] Encountered internal error running command: Error: Command 'java' not found. Is it installed?
    [MJSONWP]     at ChildProcess. (C:Usersvm510AppDataLocalProgramsAppium
    esourcesapp
    ode_modulesappium
    ode_modules	een_processlibexec.js:39:14)
    [MJSONWP]     at ChildProcess.emit (events.js:182:13)
    [MJSONWP]     at Process.ChildProcess._handle.onexit (internal/child_process.js:235:12)
    [MJSONWP]     at onErrorNT (internal/child_process.js:406:16)
    [MJSONWP]     at process._tickCallback (internal/process/next_tick.js:63:19)
    [HTTP] <-- POST /wd/hub/session 500 27 ms - 179
    [HTTP] 
    [HTTP] --> DELETE /wd/hub/session
    [HTTP] {}
    [HTTP] No route found. Setting content type to 'text/plain'
    [HTTP] <-- DELETE /wd/hub/session 404 1 ms - 57
    [HTTP] 
    [HTTP] --> POST /wd/hub/session
    [HTTP] {"desiredCapabilities":{"appActivity":".ui.LauncherUI","appPackage":"com.tencent.mm","deviceName":"MI_5X","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true}}
    [MJSONWP] Calling AppiumDriver.createSession() with args: [{"appActivity":".ui.LauncherUI","appPackage":"com.tencent.mm","deviceName":"MI_5X","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null]
    [BaseDriver] Event 'newSessionRequested' logged at 1541408028828 (16:53:48 GMT+0800 (中国标准时间))
    [Appium] Creating new AndroidDriver (v4.1.1) session
    [Appium] Capabilities:
    [Appium]   appActivity: .ui.LauncherUI
    [Appium]   appPackage: com.tencent.mm
    [Appium]   deviceName: MI_5X
    [Appium]   platformName: Android
    [Appium]   newCommandTimeout: 0
    [Appium]   connectHardwareKeyboard: true
    [BaseDriver] Creating session with MJSONWP desired capabilities: {"appActivity":".ui.Launche...
    [BaseDriver] The following capabilities were provided, but are not recognized by appium: connectHardwareKeyboard.
    [BaseDriver] Session created with session id: 26f601d9-0b75-4b0a-8f11-2a43dfc53112
    [AndroidDriver] Shutting down Android driver
    [AndroidDriver] Called deleteSession but bootstrap wasn't active
    [BaseDriver] Event 'newSessionStarted' logged at 1541408028848 (16:53:48 GMT+0800 (中国标准时间))
    [MJSONWP] Encountered internal error running command: Error: Command 'java' not found. Is it installed?
    [MJSONWP]     at ChildProcess. (C:Usersvm510AppDataLocalProgramsAppium
    esourcesapp
    ode_modulesappium
    ode_modules	een_processlibexec.js:39:14)
    [MJSONWP]     at ChildProcess.emit (events.js:182:13)
    [MJSONWP]     at Process.ChildProcess._handle.onexit (internal/child_process.js:235:12)
    [MJSONWP]     at onErrorNT (internal/child_process.js:406:16)
    [MJSONWP]     at process._tickCallback (internal/process/next_tick.js:63:19)
    [HTTP] <-- POST /wd/hub/session 500 23 ms - 179
    [HTTP] 
    [HTTP] --> DELETE /wd/hub/session
    [HTTP] {}
    [HTTP] No route found. Setting content type to 'text/plain'
    [HTTP] <-- DELETE /wd/hub/session 404 1 ms - 57
    [HTTP] 
    [HTTP] --> GET /wd/hub/sessions
    [HTTP] {}
    [GENERIC] Calling AppiumDriver.getSessions() with args: []
    [GENERIC] Responding to client with driver.getSessions() result: []
    [HTTP] <-- GET /wd/hub/sessions 200 2 ms - 40
    [HTTP] 
    [HTTP] --> GET /wd/hub/sessions
    [HTTP] {}
    [GENERIC] Calling AppiumDriver.getSessions() with args: []
    [GENERIC] Responding to client with driver.getSessions() result: []
    [HTTP] <-- GET /wd/hub/sessions 200 1 ms - 40
    [HTTP] 
  • 相关阅读:
    批量解密SQLSERVER数据库中的各种对象的工具dbForge SQL Decryptor
    微软压力测试工具 web application stress
    使用Microsoft Web Application Stress Tool对web进行压力测试
    数据库
    字体转换方法整理
    C# 开源框架
    IP、操作系统、移动OS
    互联网上的业务
    三元组与序列化
    TCP/IP协议(数据封装与拆装过程)
  • 原文地址:https://www.cnblogs.com/lvjing/p/9910067.html
Copyright © 2020-2023  润新知