赞
踩
目录
1、下载
下载JDK文件,点击运行安装
2、配置环境变量
(1)新建一个名为JAVA_HOME的环境变量,变量值为JDK的安装路径
(2)将%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin添加到path中
(3)新建一个名为classpath的环境变量,变量值为:
%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
3、验证cmd窗口中输入java -version
1、下载
下载Andorid SDK文件,点击进行安装
2、安装相关工具(默认前三个)双击Andorid SDK Manager,选择前三个tools点击安装
3、配置环境变量
(1)新建ANDROID_HOME变量,变量值为Andorid SDK的路径
(2)将%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools添加到path中
4、验证cmd窗口中输入adb,出现版本号则说明安装成功
1、下载
下载NodeJS文件,点击进行安装
2、配置环境变量自动
3、验证
cmd窗口中输入node -v,npm -v
1、下载
下载appium-desktop文件,点击进行安装
2、配置环境变量
1、pip install -U appium-python-client
1、打开手机或模拟器开发者模式
2、win+r打开cmd
3、adb connect 127.0.0.1:21503
4、adb devices -l
5、adb shell dumpsys window |findstr mCurrent
{ "deviceName": "127.0.0.1:62001", "appPackage": "com.android.launcher3", "appActivity": "com.android.launcher3.launcher3.Launcher", "platformName": "Android", "noReset": true }
- from appium import webdriver
- from appium.webdriver.common.appiumby import AppiumBy
- from appium.webdriver.common.touch_action import TouchAction
- import time
-
- desired_caps = {
- "deviceName": "127.0.0.1:62001",
- "appPackage": "com.hypergryph.arknights",
- "appActivity": "com.u8.sdk.U8UnityContext",
- "platformName": "Android",
- "noReset": True,
- "newCommandTimeout": 600
- }
-
- driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)
- actions = TouchAction(driver)
- # start、开始唤醒、取得神经连接
- time.sleep(30)
- actions.tap(x=635, y=515).perform()
- time.sleep(15)
- actions.tap(x=635, y=515).perform()
- time.sleep(40)
- # 签到
- actions.tap(x=591, y=591).perform()
- time.sleep(5)
- # 关闭签到
- actions.tap(x=1216, y=79).perform()
- time.sleep(5)
- # 关闭公告
- actions.tap(x=1236, y=74).perform()
- time.sleep(5)
- # 点击当前
- actions.tap(x=929, y=220).perform()
- time.sleep(5)
- # 点击前往上一次作战
- actions.tap(x=1137, y=602).perform()
- time.sleep(10)
- # 循环刷取关卡
- for i in range(2):
- actions.tap(x=1144, y=671).perform()
- time.sleep(10)
- actions.tap(x=1103, y=604).perform()
- time.sleep(180)
- actions.tap(x=1137, y=602).perform()
- time.sleep(15)
-
- driver.quit()
- # 安装
- driver.install_app('/Users/johndoe/path/to/app.apk')
- # 是否已安装
- driver.is_app_installed('com.example.AppName')
- # 启动
- driver.launch_app()
- # 后台应用程序
- driver.background_app(10)
- # 关闭应用程序
- driver.close_app()
- # 重启应用程序
- driver.reset()
- # 删除应用程序
- driver.remove_app('com.example.AppName')
- # 激活应用程序
- driver.activate_app('com.apple.Preferences')
- driver.activate_app('io.appium.android.apis')
- # 终止程序
- driver.terminate_app('com.apple.Preferences')
- driver.terminate_app('io.appium.android.apis')
- # 获取应用状态
- driver.query_app_state('com.apple.Preferences')
- driver.query_app_state('io.appium.android.apis')
- # 得到应用的字符串
- appStrings = driver.app_strings("en", "/path/to/file")
- # 结束测试覆盖率
- driver.end_test_coverage("Intent", "/path")
- # 查找元素
- driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="SomeAccessibilityID")
- driver.find_elements(AppiumBy.ACCESSIBILITY_ID,'SomeAccessibilityID')
- # 行为
- el = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='SomeId')
- el.click()
- el.send_keys('Hello world!')
- el.clear()
- # 元素
- el = self.driver.find_element_by_accessibility_id('SomeAccessibilityID')
- el.text
- el.tag_name
- el.get_attribute('content-desc')
- el.is_selected()
- el.is_enabled()
- el.is_displayed()
- el.location
- el.size
- from appium.webdriver.common.touch_action import TouchAction
- # ...
- actions = TouchAction(driver)
-
- # 单次点击
- actions.tap(element)
- # 双击
- actions.double_tap(element)
- # 移动
- actions.tap_and_hold(element)
- actions.move_to(element, 50, 50)
- # 向下触摸
- actions.tap_and_hold(element)
- actions.move(50, 50)
- # 向上触摸
- actions.tap_and_hold(element)
- actions.release(50, 50)
- # 长按
- actions.long_press(element)
- # 滚动
- actions.scroll_from_element(element, 10, 100)
- actions.scroll(10, 100)
- # 使用手指运动事件在触摸屏上轻拂
- actions.flick_element(element, 1, 10, 10)
- # 触摸执行
- actions.tap_and_hold(20, 20)
- actions.move_to(10, 100)
- actions.release()
-
- actions.perform()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。