feat(docs,page_objects): 完善文档以及测试用例演示

- 新增 AndroidSDK环境配置指南.md, 常用参数.md
- 更新 README.md
- 优化 wan_android_home.py, wan_android_project.py
- 其他优化
This commit is contained in:
2026-02-27 16:44:00 +08:00
parent 52758940ed
commit 332deb3666
19 changed files with 562 additions and 239 deletions

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env python
# coding=utf-8
"""
@author: CNWei,ChenWei
@Software: PyCharm
@contact: t6g888@163.com
@file: home_page
@date: 2026/1/26 17:37
@desc:
"""
from core.base_page import BasePage
class HomePage(BasePage):
_LOGOUT_BTN = ("text", "退出登录")
_NICKNAME = ("id", "user_nickname")
def get_nickname(self):
return self.driver.get_text(*self._NICKNAME)
def logout(self):
self.driver.click(*self._LOGOUT_BTN)
# 【核心:链式跳转】
# 退出后回到登录页
return self.login_page

View File

@@ -1,31 +0,0 @@
#!/usr/bin/env python
# coding=utf-8
"""
@author: CNWei,ChenWei
@Software: PyCharm
@contact: t6g888@163.com
@file: login_page
@date: 2026/1/26 17:34
@desc:
"""
from core.base_page import BasePage
from page_objects.home_page import HomePage
class LoginPage(BasePage):
# 定位参数私有化,不暴露给外面
_USER_FIELD = ("id", "com.app:id/username")
_PWD_FIELD = ("id", "com.app:id/password")
_LOGIN_BTN = ("id", "com.app:id/btn_login")
def login_as(self, username, password):
"""执行登录业务逻辑"""
# 调用继承自 CoreDriver 的方法(假设你的 CoreDriver 已经被注入或组合)
self.driver.input(*self._USER_FIELD, text=username)
self.driver.input(*self._PWD_FIELD, text=password, sensitive=True)
self.driver.click(*self._LOGIN_BTN)
# 【核心:链式跳转】
# 登录成功后,逻辑上应该进入首页,所以返回首页实例
return self.to_page(HomePage)

View File

@@ -10,7 +10,6 @@
@desc:
"""
import logging
import os
import allure
from appium import webdriver
@@ -32,7 +31,6 @@ class HomePage(BasePage):
account=("-android uiautomator",'new UiSelector().text("账号")')
pass_word=("-android uiautomator",'new UiSelector().text("密码")')
login_button = ("accessibility id", '登录')
def __init__(self, driver: webdriver.Remote):
@@ -49,21 +47,19 @@ class HomePage(BasePage):
@allure.step("登录账号:{1}")
def login(self, username, password):
"""执行登录业务逻辑"""
account_input = {"elementId": '00000000-0000-0ecb-0000-0017000002d8', "text": username}
pass_word_input = {"elementId": '00000000-0000-0ecb-0000-0018000002d8', "text": password}
account_element_id =self.find_element(*self.account).id
account_input = {"elementId": account_element_id, "text": username}
pwd_element_id =self.find_element(*self.pass_word).id
pass_word_input = {"elementId": pwd_element_id, "text": password}
if self.wait_until_visible(*self.login_button):
self.click(*self.account).driver.execute_script('mobile: type', account_input)
self.click(*self.pass_word).driver.execute_script('mobile: type', pass_word_input)
self.click(*self.login_button).full_screen_screenshot()
self.click(*self.login_button)
if self.wait_until_visible(*self.tv_name):
self.full_screen_screenshot("登陆成功")
self.long_press(x=636,y=117,duration=300)
# @allure.step("获取 “Text ”文本")
# def get_home_text(self):
# """执行登录业务逻辑"""os.getenv("USER_NAME") os.getenv("PASS_WORD")
# # 调用继承自 CoreDriver 的方法(假设你的 CoreDriver 已经被注入或组合)
# """
# { "elementId": "00000000-0000-0ecb-0000-0017000002d8", "text": "admintest123456" }
# { "elementId": "00000000-0000-0ecb-0000-0018000002d8", "text": "admin123456" }
# """
#
# return self.get_text(*self.text)

View File

@@ -0,0 +1,39 @@
#!/usr/bin/env python
# coding=utf-8
"""
@author: CNWei,ChenWei
@Software: PyCharm
@contact: t6g888@163.com
@file: test_views
@date: 2026/1/30 17:37
@desc:
"""
import logging
import allure
from appium import webdriver
from core.base_page import BasePage
from utils.decorators import StepTracer
logger = logging.getLogger(__name__)
class ProjectPage(BasePage):
# 定位参数
project_title = ("-android uiautomator", 'new UiSelector().text("项目")')
pro_table_title = ("-android uiautomator",'new UiSelector().text("完整项目")')
def __init__(self, driver: webdriver.Remote):
super().__init__(driver)
@allure.step("切换到“项目”页面")
def switch_to_project(self):
self.click(*self.project_title).attach_screenshot_bytes()
@allure.step("滑动切换“项目”内容")
@StepTracer("页面滑动")
def slide_views(self):
with allure.step("向左滑动3次"):
with StepTracer("开始划了"):
for _ in range(3):
self.swipe("left")

View File

@@ -1,33 +0,0 @@
#!/usr/bin/env python
# coding=utf-8
"""
@author: CNWei,ChenWei
@Software: PyCharm
@contact: t6g888@163.com
@file: test_views
@date: 2026/1/30 17:37
@desc:
"""
import logging
import allure
from appium import webdriver
from core.base_page import BasePage
logger = logging.getLogger(__name__)
class ViewsPage(BasePage):
# 定位参数
views = ("accessibility id","Views")
def __init__(self, driver: webdriver.Remote):
super().__init__(driver)
@allure.step("截图 “Views ”")
def screenshot_views(self):
if self.wait_until_visible(*self.views):
with allure.step("发现Views开始执行点击"):
self.log_screenshot_bytes("Text截图")