feat(core,utils): 新增CoreDriver基础操作,更新文档
- 新增 switch_to_webview/switch_to_native 切换视图。 - 新增 config_loader.py 配置文件系统 - 优化 conftest.py,支持获取设备信息和默认参数。 - 优化 run_appium.py - 更新 README.md - 其他优化
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
@desc:
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
|
||||
import allure
|
||||
from appium import webdriver
|
||||
@@ -22,13 +23,18 @@ logger = logging.getLogger(__name__)
|
||||
class HomePage(BasePage):
|
||||
# 定位参数
|
||||
menu = ("accessibility id", "开启")
|
||||
home = ("-android uiautomator", 'new UiSelector().resourceId("com.manu.wanandroid:id/icon").instance(0)')
|
||||
home = ("id", 'com.manu.wanandroid:id/largeLabel')
|
||||
project = ("-android uiautomator", 'new UiSelector().text("项目")')
|
||||
system = ("-android uiautomator", 'new UiSelector().text("体系")')
|
||||
|
||||
|
||||
tv_name = ("id", "com.manu.wanandroid:id/tvName")
|
||||
|
||||
account=("-android uiautomator",'new UiSelector().text("账号")')
|
||||
pass_word=("-android uiautomator",'new UiSelector().text("密码")')
|
||||
|
||||
|
||||
login_button = ("accessibility id", '登录')
|
||||
|
||||
def __init__(self, driver: webdriver.Remote):
|
||||
super().__init__(driver)
|
||||
|
||||
@@ -41,17 +47,23 @@ class HomePage(BasePage):
|
||||
self.click(*self.tv_name)
|
||||
|
||||
@allure.step("登录账号:{1}")
|
||||
def click_unicode(self, username,password):
|
||||
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}
|
||||
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)
|
||||
|
||||
if self.wait_until_visible(*self.unicode):
|
||||
self.swipe("left")
|
||||
self.click(*self.login_button).full_screen_screenshot()
|
||||
|
||||
self.click(*self.unicode).log_screenshot()
|
||||
|
||||
@allure.step("获取 “Text ”文本")
|
||||
def get_home_text(self):
|
||||
"""执行登录业务逻辑"""
|
||||
# 调用继承自 CoreDriver 的方法(假设你的 CoreDriver 已经被注入或组合)
|
||||
|
||||
return self.get_text(*self.text)
|
||||
# @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)
|
||||
|
||||
Reference in New Issue
Block a user