#! /usr/bin/env pyhton
# -*- coding:utf-8 -*-
# author:jeff.xie
# datetime:2024/4/11 16:54
# software:PyCharm
import subprocess
from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from time import sleep
import time
def appium_start(host, port):
# 指定bp端口号
bootstrap_root = str(port+1)
# 把cmd弹窗输入的命令,直接些在这里
cmd = 'start /b appium -a ' + host + ' -p ' +str(port)+' -bp ' +str(bootstrap_root)
# 去掉 /b 即可打开cmd弹窗运行
cmd = 'start appium -a ' + host + ' -p ' +str(port)+' -bp ' +str(bootstrap_root)
#打印输入的cmd命令以及时间
print('%s at %s' %(cmd, time.ctime()))
subprocess.Popen(cmd, shell= True, stdout=open('./appium_log/'+str(port)+'.log','a'), stderr=subprocess.STDOUT)
def run_case(host, port):
print(time.strftime("%H:%M:%S"))
desired_caps = {}
# 系统
desired_caps['platformName'] = 'Android'
# 手机版本,在手机中:设置--关于手机
desired_caps['platformVersion'] = '11'
# 设备号
desired_caps['deviceName'] = '9b2157cfaedb'
# 包名
desired_caps['appPackage'] = 'welab.bank.mobile.stage'
# desired_caps['appPackage'] = 'welab.bank.sit'
# # 启动名
desired_caps['appActivity'] = 'com.welabfrontend.MainActivity'
# desired_caps["unicodeKeyboard"] = "True"#appium提供的一种输入法,可以传中文。测试时直接用这个输入法
# desired_caps["resetKeyboard"] = "True"#程序结束时重置原来的输入法
# desired_caps["noReset"] = "True"#不初始化手机app信息(类似不清除缓存)
# driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)
driver = webdriver.Remote("http://"+host+":"+str(port)+"/wd/hub", desired_caps)
driver.wait_activity("com.welabfrontend.MainActivity", 50)
sleep(5)
print(time.strftime("%H:%M:%S"))
if __name__ == '__main__':
host = '127.0.0.1'
# 运行一个端口
port = 4723
appium_start(host, port)
run_case(host, port)
Python 启动Appium Service然后执行APP自动化case
qq_4924484462024-04-16 19:22
相关推荐
消失的旧时光-194330 分钟前
统一并发模型:线程、Reactor、协程本质是一件事(从线程到协程 · 第6篇·终章)易生一世36 分钟前
自动化Pipeline中的Kiro CLI详解zhaoyong2222 小时前
MySQL 存储过程中字符集与排序规则不匹配导致查询性能下降的解决方案sinat_383437362 小时前
golang如何从Python转型Go开发_golang从Python转型Go开发攻略rockey6272 小时前
基于AScript的python3脚本语言发布啦!gqk012 小时前
Python入门Muyuan19983 小时前
28.Paper RAG Agent 开发记录:修复 LLM Rerank 的解析、Fallback 与可验证性代码小书生3 小时前
statistics,一个统计的 Python 库!薛定猫AI3 小时前
【深度解析】Kimi K2.6 的长上下文 Agentic Coding 能力与 OpenAI 兼容 API 接入实践STLearner4 小时前
SIGIR 2026 | LLM × Graph论文总结(图增强LLM,GraphRAG,Agent,多模态,知识图谱,搜索,推