zoukankan      html  css  js  c++  java
  • adb如何连接mumu模拟器

    adb如何连接mumu模拟器

    【win版】
    adb connect 127.0.0.1:7555
    adb shell

    如果在本地配置安装了appium测试环境,运行即可验证

    # coding=utf-8
    # 模拟移动端首次安装手指滑动操作
    
    from appium import webdriver
    
    
    def get_driver():
        capabilities = {
            "platformName": "Android",
            "platformVersion": "6.0.1",
            # "deviceName": "bd619e047cf3",
            "deviceName": "127.0.0.1:7555",
            "app": "D:\Android\open_mooc_701_.apk",
            # "appPackage":新版Appium1.19.1无需手动配置
            # "appActivity":新版Appium1.19.1无需手动配置
            "appPackage":"cn.com.open.mooc",
            "appWaitActivity": "com.imooc.component.imoocmain.splash.GuideActivity"
    
        }
        driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", capabilities)
        return driver
    
    
    # driver.swipe(x,y,x1,y1)
    # driver.swipe(500,400,50,400) #水平从右向左滑动
    # 获取屏幕像素的宽和高
    # size = driver.get_window_size()
    # width = size['width']
    # height = size['height']
    
    
    # 获取屏幕像素宽和高,方法封装
    def get_size():
        # driver = get_driver()
        size = driver.get_window_size()
        width = size['width']
        height = size['height']
        return width, height
    
    
    # 手指向左滑动,方法封装
    def swipe_left():
        x = get_size()[0] / 10 * 9
        y1 = get_size()[1] / 2
        x1 = get_size()[0] / 10
        # driver = get_driver()
        driver.swipe(x, y1, x1, y1)
    
    
    # 手指向右滑动,方法封装
    def swipe_right():
        x = get_size()[0] / 10
        y1 = get_size()[1] / 2
        x1 = get_size()[0] / 10 * 9
        # driver = get_driver()
        driver.swipe(x, y1, x1, y1)
    
    
    # 手指向上滑动,方法封装
    def swipe_up():
        x = get_size()[0] / 2
        y = get_size()[1] / 10 * 9
        y1 = get_size()[1] / 10
        x1 = get_size()[0] / 2
        # driver = get_driver()
        driver.swipe(x, y, x1, y1)
    
    
    # 手指向下滑动,方法封装
    def swipe_down():
        x = get_size()[0] / 2
        y = get_size()[1] / 10
        y1 = get_size()[1] / 10 * 9
        x1 = get_size()[0] / 2
        # driver = get_driver()
        driver.swipe(x, y, x1, y1)
    
    
    # 进一步封装,滑动的方法
    def swipe_on(direction):
        if direction == 'up':
            swipe_up()
        elif direction == 'down':
            swipe_down()
        elif direction == 'left':
            swipe_left()
        else:
            swipe_right()
    
    
    if __name__ == '__main__':
        driver = get_driver() #获取一个全局变量
        swipe_on('left')
        swipe_on('left')
  • 相关阅读:
    windows运行shell脚本
    Android Webview H5资源本地化
    Vscode开发Python环境安装
    Vscode开发Java环境搭建
    为什么索引可以提高效率?
    Java内存模型
    栈和队列----向有序的环形单链表中插入新节点
    栈和队列----单链表的选择排序
    栈和队列----将搜索二叉树转换成双向链表
    栈和队列----在单链表中删除指定值的节点
  • 原文地址:https://www.cnblogs.com/MarlonKang/p/14184053.html
Copyright © 2011-2022 走看看