• 获取手机当前时间以及分辨率,使用系统键、打开通知栏、获取网络设置网络、截取当前屏幕(六)


    from init_driver.Init_driver import init_driver
    import time
    
    driver = init_driver()
    
    # 获取手机当前时间
    phone_now_time = driver.device_time
    print(phone_now_time)
    
    # 获取手机分辨率
    phone_resolution = driver.get_window_size()
    # 使用手机分辨率进行滑动
    x = phone_resolution.get("height") / 2
    y_0 = phone_resolution.get("width") * 0.8
    y_1 = phone_resolution.get("width") * 0.2
    driver.swipe(x, y_0, x, y_1, 10000)
    
    # 使用系统键,官方文档:https://developer.android.com/reference/android/view/KeyEvent.html
    driver.keyevent(3)
    
    # 打开通知栏
    driver.open_notifications()
    time.sleep(5)
    # 模拟在通知栏处,点击通知信息进入软件页面
    driver.find_element_by_xpath("//*[contains(@text, '最美天气大事件')]").click()
    time.sleep(5)
    # 点击HOME键
    driver.keyevent(3)
    
    # 获取网络:0(None) 1(AirplaneMode) 2(Wifionly) 4(Dataonly) 6(Allnetworkon)
    print(driver.network_connection)
    # 设置网络模式
    driver.set_network_connection(2)
    
    # 截取当前屏幕,最好新建一个文件夹,把所有的截图保存在里面
    driver.get_screenshot_as_file("./screenshot_page/test1.png")
    
    driver.quit()
  • 相关阅读:
    js 复制 浏览器 点击 copy
    php 百度地图 腾讯地图 转换坐标
    Excel PHP html select option 替换
    python教程
    Eclipse 总是在编译的时候卡住
    python+Eclipse+pydev环境搭建1
    python+Eclipse+pydev环境搭建
    Pycharm
    如何卸载eclipse中的pydev
    Eclipse的PyDev插件安装及解决安装后找不到的问题
  • 原文地址:https://www.cnblogs.com/zhaoquanmo/p/10734895.html
Copyright © 2020-2023  润新知