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')
  • 相关阅读:
    爬取淘宝商品信息
    eclipse 搭建Robotium环境--apk 环境搭建
    android studio2.0 搭建Robotium环境--有被测源代码的情况下
    mysql 特殊语句
    电脑浏览器访问文件夹
    mindmanager 15 停止工作
    yum被lock Existing lock /var/run/yum.pid: another copy is running as pid 1580. Another app is currently holding the yum lock; waiting for it to exi
    jenkins安装及部署
    ant+jmeter
    charles抓包及篡改
  • 原文地址:https://www.cnblogs.com/MarlonKang/p/14184053.html
Copyright © 2011-2022 走看看