from selenium.webdriver.common.by import By
import time
# 设置 Appium 连接参数
caps = {
"platformName": "Android",
"platformVersion": "7.1.2", # 根据夜神模拟器的 Android 版本进行修改
"deviceName": "127.0.0.1:62001", # 设备名称,可以根据实际情况更改
"appPackage": "com.loyo.oa.v2", # 替换为待测试应用的包名
"appActivity": "com.loyo.oa.v2.home.LoginActivity", # 替换为待测试应用的主活动
"noReset": True , # 不重置应用状态
}
# 创建 Appium 驱动
driver = webdriver.Remote("http://127.0.0.1:6666/wd/hub", caps)
try:
# 等待应用加载
# 示例:查找元素并点击
driver.find_element(By.ID,"com.loyo.oa.v2:id/edt_login_name").send_keys("18408286152")
# 示例:输入文本
driver.find_element(By.ID,"com.loyo.oa.v2:id/edt_login_password").send_keys("123456")
# 其他操作可继续添加
driver.find_element(By.ID,"com.loyo.oa.v2:id/btn_login").click() #登录
time.sleep(5)
finally:
# 退出驱动
driver.quit()
标签:appium,loyo,示例,python,driver,oa,v2,com
From: https://www.cnblogs.com/striver-dl/p/18425770