安装Appium-desktop,并连接模拟器!Appium-Python-Client

时间:2024-01-04 08:14:44

1.下载appium-desktop

https://github.com/appium/appium-desktop/releases

2.双击 exe 文件,然后,等待安装完就好了

3.启动appium-desktop,需要先启动虚拟机

安装Appium-desktop,并连接模拟器!Appium-Python-Client

安装Appium-desktop,并连接模拟器!Appium-Python-Client

4.点击左上角的"start inspector session"按钮进入到server配置界面,此处的配置相当于appium的"Capabilities"项

安装Appium-desktop,并连接模拟器!Appium-Python-Client

5.在android的sdk中的adb.exe目录下输入cmd进入命令行,在命令行输入以下命令获取appPackage和appActivity,需要先启动虚拟机

安装Appium-desktop,并连接模拟器!Appium-Python-Client

安装Appium-desktop,并连接模拟器!Appium-Python-Client

adb shell dumpsys window w |findstr \/ |findstr name=

6.获取deviceName,需要先启动虚拟机

安装Appium-desktop,并连接模拟器!Appium-Python-Client

安装Appium-desktop,并连接模拟器!Appium-Python-Client

7.配置示例

安装Appium-desktop,并连接模拟器!Appium-Python-Client

8.启动页面

安装Appium-desktop,并连接模拟器!Appium-Python-Client

9.appium客户端代码示例

# coding=utf-8
import time

from appium import webdriver

if __name__ == '__main__':
    desired_caps = {}
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '9'
    desired_caps['deviceName'] = 'emulator-5554'
    desired_caps['appPackage'] = 'com.android.calculator2'
    desired_caps['appActivity'] = '.Calculator'
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    driver.find_element_by_id('com.android.calculator2:id/digit_1').click()
    driver.find_element_by_id('com.android.calculator2:id/op_add').click()
    driver.find_element_by_id('com.android.calculator2:id/digit_8').click()
    driver.find_element_by_id('com.android.calculator2:id/eq').click()
    time.sleep(1)
    driver.quit()

获取id:

ps:

真机调试道理一样,只是将虚拟机变为真机,配置也是读取真机的配置