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()
原文地址:https://www.cnblogs.com/zhaoquanmo/p/10734895.html
时间: 2024-11-01 23:14:55