Update test framework: fix run_tests.py to support all test files, add auto-import-check for test files

This commit is contained in:
qiaoxinjiu
2026-05-09 15:11:30 +08:00
parent eb053a347f
commit eaba8328da
21739 changed files with 2236758 additions and 719 deletions

View File

@@ -0,0 +1,4 @@
# -*- coding:utf-8 -*-
# @Time : 2023/10/11 14:32
# @Author: luozhipeng
# @File : __init__.py.py

View File

@@ -0,0 +1,202 @@
from airtest.core.api import *
import logging
import allure
import os
import sys
LOCAL_PATH = os.path.dirname(os.path.abspath(__file__))
BASE_PROJECT_PATH = os.path.abspath(os.path.join(LOCAL_PATH, '../../../../../../../{}'.format("UBRD")))
BASIC_PATH = os.path.abspath(os.path.join(LOCAL_PATH, '../../../../../../../'))
sys.path.append(BASE_PROJECT_PATH)
sys.path.append(BASIC_PATH)
from ui_library.page.student.huohua.PC.view.view import View
from base_framework.public_tools.apollo import Apollo
from library.CommonFun.host_update import HostUpdate,CoreApollo
from ui_library.page.student.spark.PC.login.spark_pc_login import SparkPCLogin
from ui_library.page.student.spark.PC.home.spark_pc_home import SparkPCHome
from ui_library.page.student.spark.PC.classroom.spark_pc_classroom import SparkPCClassroom
import subprocess
import shutil
logger = logging.getLogger("airtest")
logger.setLevel(logging.ERROR)
host_update = HostUpdate()
obj_core_apollo = CoreApollo()
@allure.feature('Spark Student')
class TestSparkStudentLogin:
def setup(self):
self.host_list = []
# 打开APP
# nginx = subprocess.Popen(['C:\\Users\\Administrator\\Downloads\\nginx-1.24.0\\nginx.exe', '-p', '.'], cwd=r"C:\Users\Administrator\Downloads\nginx-1.24.0")
file_path = r"C:\Users\Administrator\AppData\Roaming\overseas-pc-student-sim\db.json"
source_file = r"C:\Users\Administrator\AppData\Roaming\st-oversea\db.json"
if os.path.isfile(file_path):
os.remove(file_path)
shutil.copy(source_file, file_path)
subprocess.Popen(['C:\\Users\\Administrator\\AppData\\Local\\Programs\\overseas-pc-student-sim\\SparkMath学生端 - SIM.exe'])
sleep(20)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*Spark Education*"])
SparkPCHome().login_out()
def teardown(self):
for i in self.host_list:
host_update.host_remove_intercept(i["ip"],i["host_name"])
os.system("ipconfig /flushdns")
subprocess.call(['taskkill', '/F', '/IM', 'SparkMath学生端 - SIM.exe'])
# subprocess.call(['taskkill', '/F', '/IM', 'nginx.exe'])
@allure.title("[海外学生端PC前端域名降级--001]")
def test_student_login_by_pwd_low_fe(self):
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*Spark Education*"])
with allure.step("清理客户端缓存"):
file_path = r"C:\Users\Administrator\AppData\Roaming\overseas-pc-student-sim\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
with allure.step("清除前端缓存"):
View().input_console_command("await{ }window._NATIVE.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("点击密码登录"):
sleep(5)
SparkPCLogin().click_via_pwd()
with allure.step("输入手机号12345678001"):
SparkPCLogin().input_user_phone("12345678001")
with allure.step("输入密码123456"):
SparkPCLogin().input_user_pwd("123456")
with allure.step("点击同意协议"):
SparkPCLogin().click_agree_label()
with allure.step("点击登录按钮"):
SparkPCLogin().click_login_button()
sleep(15)
with allure.step("确认登录成功"):
default_status = SparkPCLogin().get_login_button()
if default_status:
SparkPCLogin().click_login_button()
sleep(10)
sleep(10)
SparkPCHome().check_spark_icon()
@allure.title("[海外学生端PC腾讯验证码降级--002]")
def test_student_login_low_ten(self):
with allure.step("添加域名屏蔽"):
self.host_list = [{"ip": "1.1.1.1", "host_name": "turing.captcha.qcloud.com"}]
host_update.host_update_by_host_dict(self.host_list)
host_update.wait_dns_flush(ip="1.1.1.1" ,domain= "turing.captcha.qcloud.com")
file_path = r"C:\Users\Administrator\AppData\Roaming\overseas-pc-student-sim\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', 'SparkMath学生端 - SIM.exe'])
subprocess.Popen(
['C:\\Users\\Administrator\\AppData\\Local\\Programs\\overseas-pc-student-sim\\SparkMath学生端 - SIM.exe'])
sleep(20)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*Spark Education*"])
SparkPCHome().login_out()
with allure.step("清除前端缓存"):
View().input_console_command("await{ }window._NATIVE.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("输入手机号13460219197"):
SparkPCLogin().input_user_phone("13460219197")
with allure.step("点击同意协议"):
SparkPCLogin().click_agree_label()
with allure.step("点击获取验证码"):
SparkPCLogin().click_get_code()
sleep(10)
with allure.step("确认不存在腾讯验证码"):
SparkPCLogin().assert_no_tencent_button()
@allure.title("[海外学生端PC腾讯验证码正常流程--003]")
def test_student_login_normal_ten(self):
with allure.step("清除客户端缓存"):
file_path = r"C:\Users\Administrator\AppData\Roaming\overseas-pc-student-sim\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', 'SparkMath学生端 - SIM.exe'])
subprocess.Popen(
['C:\\Users\\Administrator\\AppData\\Local\\Programs\\overseas-pc-student-sim\\SparkMath学生端 - SIM.exe'])
sleep(20)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*Spark Education*"])
SparkPCHome().login_out()
with allure.step("清除前端缓存"):
View().input_console_command("await{ }window._NATIVE.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("输入手机号13460219197"):
SparkPCLogin().input_user_phone("13460219197")
with allure.step("点击同意协议"):
SparkPCLogin().click_agree_label()
with allure.step("点击获取验证码"):
SparkPCLogin().click_get_code()
sleep(10)
with allure.step("确认存在腾讯验证码"):
SparkPCLogin().assert_exist_tencent_button()
@allure.title("[海外学生端PC磐石登录成功--004]")
def test_student_login_by_pwd_normal(self):
with allure.step("清除客户端缓存"):
file_path = r"C:\Users\Administrator\AppData\Roaming\overseas-pc-student-sim\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', 'SparkMath学生端 - SIM.exe'])
subprocess.Popen(
['C:\\Users\\Administrator\\AppData\\Local\\Programs\\overseas-pc-student-sim\\SparkMath学生端 - SIM.exe'])
sleep(10)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*Spark Education*"])
with allure.step("清除前端缓存"):
View().input_console_command("await{ }window._NATIVE.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("点击密码登录"):
sleep(5)
SparkPCLogin().click_via_pwd()
with allure.step("输入手机号13460219197"):
SparkPCLogin().input_user_phone("13460219197")
with allure.step("输入密码123456"):
SparkPCLogin().input_user_pwd("123456")
sleep(1)
with allure.step("点击同意协议"):
SparkPCLogin().click_agree_label()
with allure.step("点击登录按钮"):
SparkPCLogin().click_login_button()
sleep(5)
with allure.step("确认登录成功"):
default_status = SparkPCLogin().get_login_button()
if default_status:
SparkPCLogin().click_login_button()
sleep(10)
SparkPCHome().check_spark_icon()
@allure.title("[海外学生端PC强制验证码登录进入课堂上课--005]")
def test_student_join_classroom_check(self):
with allure.step("添加域名重定向降级服务"):
self.host_list = [{"ip": "127.0.0.1", "host_name": "core-api.sim.huohua.cn"}]
host_update.host_update_by_host_dict(self.host_list)
host_update.wait_dns_flush(ip="127.0.0.1" ,domain= "core-api.sim.huohua.cn")
file_path = r"C:\Users\Administrator\AppData\Roaming\overseas-pc-student-sim\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', 'SparkMath学生端 - SIM.exe'])
subprocess.Popen(
['C:\\Users\\Administrator\\AppData\\Local\\Programs\\overseas-pc-student-sim\\SparkMath学生端 - SIM.exe'])
sleep(20)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*Spark Education*"])
SparkPCHome().login_out()
with allure.step("清除前端缓存"):
View().input_console_command("await{ }window._NATIVE.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
sleep(2)
with allure.step("输入手机号15890630602"):
SparkPCLogin().input_user_phone("15890630602")
with allure.step("点击同意协议"):
SparkPCLogin().click_agree_label()
with allure.step("点击输入验证码"):
SparkPCLogin().input_user_code("8888")
with allure.step("点击登录按钮"):
SparkPCLogin().click_login_by_code()
sleep(5)
with allure.step("确认登录成功"):
SparkPCHome().check_spark_icon()
sleep(8)
with allure.step("点击进入课堂按钮"):
SparkPCHome().click_enter_class_button()
sleep(15)
with allure.step("检查课堂内宝箱图标"):
SparkPCClassroom.check_classroom_star_box()
if __name__ == '__main__':
TestSparkStudentLogin().test_student_login_by_pwd_low_fe()

View File

@@ -0,0 +1,189 @@
from airtest.core.api import *
import logging
import allure
import os
import sys
LOCAL_PATH = os.path.dirname(os.path.abspath(__file__))
BASE_PROJECT_PATH = os.path.abspath(os.path.join(LOCAL_PATH, '../../../../../../../{}'.format("UBRD")))
BASIC_PATH = os.path.abspath(os.path.join(LOCAL_PATH, '../../../../../../../'))
sys.path.append(BASE_PROJECT_PATH)
sys.path.append(BASIC_PATH)
from ui_library.page.student.huohua.PC.view.view import View
from base_framework.public_tools.apollo import Apollo
from library.CommonFun.host_update import HostUpdate,CoreApollo
from ui_library.page.student.spark.PC.login.spark_pc_login import SparkPCLogin
from ui_library.page.student.spark.PC.home.spark_pc_home import SparkPCHome
from ui_library.page.student.spark.PC.classroom.spark_pc_classroom import SparkPCClassroom
import subprocess
import shutil
logger = logging.getLogger("airtest")
logger.setLevel(logging.ERROR)
host_update = HostUpdate()
obj_core_apollo = CoreApollo()
@allure.feature('Spark Student')
class TestSparkStudentLogin:
def setup(self):
self.host_list = []
# 打开APP
# nginx = subprocess.Popen(['C:\\Users\\Administrator\\Downloads\\nginx-1.24.0\\nginx.exe', '-p', '.'], cwd=r"C:\Users\Administrator\Downloads\nginx-1.24.0")
file_path = r"C:\Users\Administrator\AppData\Roaming\sparkedu-learner-client\db.json"
source_file = r"C:\Users\Administrator\AppData\Roaming\on_spark\db.json"
if os.path.isfile(file_path):
os.remove(file_path)
shutil.copy(source_file, file_path)
subprocess.Popen(['C:\\Users\\Administrator\\AppData\\Local\\Programs\\sparkedu-learner-client\\SparkMath学生端.exe'])
sleep(20)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*Spark Education*"])
SparkPCHome().login_out()
def teardown(self):
for i in self.host_list:
host_update.host_remove_intercept(i["ip"],i["host_name"])
os.system("ipconfig /flushdns")
subprocess.call(['taskkill', '/F', '/IM', 'SparkMath学生端.exe'])
# subprocess.call(['taskkill', '/F', '/IM', 'nginx.exe'])
@allure.title("[海外学生端PC前端域名降级--001]")
def test_student_login_by_pwd_low_fe(self):
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*Spark Education*"])
with allure.step("添加域名屏蔽"):
file_path = r"C:\Users\Administrator\AppData\Roaming\sparkedu-learner-client\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
with allure.step("清除前端缓存 域名重新轮询"):
View().input_console_command("await{ }window._NATIVE.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("点击密码登录"):
SparkPCLogin().click_via_pwd()
with allure.step("输入手机号12345678001"):
SparkPCLogin().input_user_phone("12345678001")
with allure.step("输入密码123456"):
SparkPCLogin().input_user_pwd_online("123456")
sleep(5)
with allure.step("点击同意协议"):
SparkPCLogin().click_agree_label()
with allure.step("第一次点击登录按钮"):
SparkPCLogin().click_login_button()
sleep(5)
with allure.step("第二次点击登录按钮"):
SparkPCLogin().click_login_button()
sleep(10)
with allure.step("第三次点击登录按钮"):
SparkPCLogin().click_login_button()
sleep(10)
with allure.step("确认登录成功"):
SparkPCHome().check_spark_icon()
@allure.title("[海外学生端PC腾讯验证码降级--002]")
def test_student_login_low_ten(self):
with allure.step("添加域名屏蔽"):
self.host_list = [{"ip": "1.1.1.1", "host_name": "turing.captcha.qcloud.com"}]
host_update.host_update_by_host_dict(self.host_list)
host_update.wait_dns_flush(ip="1.1.1.1" ,domain= "turing.captcha.qcloud.com")
file_path = r"C:\Users\Administrator\AppData\Roaming\sparkedu-learner-client\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', 'SparkMath学生端.exe'])
subprocess.Popen(
['C:\\Users\\Administrator\\AppData\\Local\\Programs\\sparkedu-learner-client\\SparkMath学生端.exe'])
sleep(20)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*Spark Education*"])
with allure.step("清除前端缓存"):
View().input_console_command("await{ }window._NATIVE.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("输入手机号18333586570"):
SparkPCLogin().input_user_phone("18333586570")
with allure.step("点击同意协议"):
SparkPCLogin().click_agree_label()
with allure.step("点击获取验证码"):
SparkPCLogin().click_get_code()
with allure.step("确认不存在腾讯验证码"):
SparkPCLogin().assert_no_tencent_button()
@allure.title("[海外学生端PC腾讯验证码正常流程--003]")
def test_student_login_normal_ten(self):
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*Spark Education*"])
file_path = r"C:\Users\Administrator\AppData\Roaming\sparkedu-learner-client\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
with allure.step("清除前端缓存"):
View().input_console_command("await{ }window._NATIVE.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("输入手机号18333586570"):
SparkPCLogin().input_user_phone("18333586570")
with allure.step("点击同意协议"):
SparkPCLogin().click_agree_label()
with allure.step("点击获取验证码"):
SparkPCLogin().click_get_code()
with allure.step("确认存在腾讯验证码"):
SparkPCLogin().assert_exist_tencent_button()
@allure.title("[海外学生端PC磐石登录成功--004]")
def test_student_login_by_pwd_normal(self):
with allure.step("添加域名屏蔽"):
file_path = r"C:\Users\Administrator\AppData\Roaming\sparkedu-learner-client\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
with allure.step("清除前端缓存"):
View().input_console_command("await{ }window._NATIVE.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("点击密码登录"):
sleep(2)
SparkPCLogin().click_via_pwd()
sleep(3)
with allure.step("输入手机号18333586570"):
SparkPCLogin().input_user_phone("18333586570")
with allure.step("输入密码123456"):
SparkPCLogin().input_user_pwd_online("123456")
sleep(5)
with allure.step("点击同意协议"):
SparkPCLogin().click_agree_label()
with allure.step("点击登录按钮"):
SparkPCLogin().click_login_button()
sleep(5)
with allure.step("确认登录成功"):
default_status = SparkPCLogin().get_login_button()
if default_status:
SparkPCLogin().click_login_button()
sleep(10)
SparkPCHome().check_spark_icon()
@allure.title("[海外学生端PC强制验证码登录进入课堂上课--005]")
def test_student_join_classroom_check(self):
with allure.step("添加域名重定向"):
self.host_list = [{"ip": "127.0.0.1", "host_name": "core-api.sparkeduapi.com"}]
host_update.host_update_by_host_dict(self.host_list)
host_update.wait_dns_flush(ip="127.0.0.1" ,domain= "core-api.sparkeduapi.com")
file_path = r"C:\Users\Administrator\AppData\Roaming\sparkedu-learner-client\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', 'SparkMath学生端.exe'])
subprocess.Popen(
['C:\\Users\\Administrator\\AppData\\Local\\Programs\\sparkedu-learner-client\\SparkMath学生端.exe'])
sleep(10)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*Spark Education*"])
SparkPCHome().login_out()
with allure.step("清除前端缓存"):
View().input_console_command("await{ }window._NATIVE.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("输入手机号15890630602"):
SparkPCLogin().input_user_phone("15890630602")
with allure.step("点击同意协议"):
SparkPCLogin().click_agree_label()
with allure.step("点击输入验证码"):
SparkPCLogin().input_user_code("8888")
with allure.step("点击登录按钮"):
SparkPCLogin().click_login_by_code()
sleep(5)
with allure.step("确认登录成功"):
SparkPCHome().check_spark_icon()
sleep(10)
with allure.step("点击进入课堂按钮"):
SparkPCHome().click_enter_class_button()
sleep(20)
with allure.step("检查课堂内宝箱图标"):
SparkPCClassroom.check_classroom_star_box()
if __name__ == '__main__':
TestSparkStudentLogin().test_student_login_by_pwd_low_fe()

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# __author__ = 'luozhipeng'
import allure
from airtest.core.api import *
from ui_auto_lego.common import handle_driver
from ui_library.page.student import login, home
from ui_library.common.read_config import readconfig
from ui_auto_lego.common.launch import InitMobilStartApp
handle_driver_obj = handle_driver.HandleDriver()
login_page = login.Login()
home_page = home.Home()
rf_config = readconfig()
user_info = eval(rf_config.study_user)
@allure.feature('ViSpark Study 日历标识测试')
class TestCalendarSign(object):
init_mobile_start_app = InitMobilStartApp()
poco_driver = init_mobile_start_app.poco_driver
def setup(self):
# 启动被测试应用
self.init_mobile_start_app.launch_app()
def teardown(self):
# 退出被测试应用并清理数据
self.init_mobile_start_app.quit()

View File

@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-
# __author__ = 'luozhipeng'
from airtest.core.api import *
import allure
from ui_auto_lego.common.handle_action import HandleAction
from ui_auto_lego.common.handle_driver import HandleDriver
from ui_library.page.student import login, home,schedule,homework,assessment,setting
from ui_library.common.read_config import readconfig
from ui_auto_lego.common.launch import InitMobilStartApp
from ui_library.logic.student.login_logic import LoginLogic
obj_handle_action = HandleAction()
obj_handle_driver = HandleDriver()
obj_login_page = login.Login()
obj_home_page = home.Home()
obj_homework_page = homework.Homework()
obj_assessment_page = assessment.Assessment()
obj_setting_page = setting.Setting()
obj_schedule_page = schedule.Schedule()
obj_rf_config = readconfig()
obj_login_logic = LoginLogic()
obj_user_info = eval(obj_rf_config.study_user)
@allure.feature('ViSpark Study 首页测试')
class TestHome(object):
init_mobile_start_app = InitMobilStartApp()
poco_driver = init_mobile_start_app.poco_driver
def setup(self):
# 启动被测试应用
# self.init_mobile_start_app.launch_app()
pass
def teardown(self):
# 退出被测试应用并清理数据
pass
# self.init_mobile_start_app.quit()
# self.init_mobile_start_app.clear_app()
@allure.title("首页页面跳转")
def test_home_schedule(self):
with allure.step("点击课后任务项"):
poco = self.poco_driver
obj_handle_action.click_by_poco(poco, obj_home_page.get_left_menu_homework())
assert obj_handle_action.is_exists_by_poco(poco, obj_homework_page.get_homework_course_task_container())
with allure.step("点击课表项"):
obj_handle_action.click_by_poco(poco, obj_home_page.get_left_menu_schedule())
assert obj_handle_action.is_exists_by_poco(poco,obj_schedule_page.get_schedule_avatar())
with allure.step("点击我的测评项"):
obj_handle_action.click_by_poco(poco, obj_home_page.get_left_menu_assessment())
assert obj_handle_action.is_exists_by_poco(poco, obj_assessment_page.get_assessment_testList())
with allure.step("点击设置按钮"):
obj_handle_action.click_by_poco(poco, obj_home_page.get_left_menu_setting())
assert obj_handle_action.is_exists_by_poco(poco, obj_setting_page.get_setting_title())
obj_handle_action.click_by_poco(poco,obj_setting_page.get_setting_close_location())
with allure.step("检查菜单目录logo"):
assert obj_handle_action.is_exists_by_poco(poco, obj_home_page.get_left_menu_logo())
if __name__ == '__main__':
A = TestHome()
A.test_home_schedule()

View File

@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
# __author__ = 'xinjiu.qiao'
import allure
from ui_auto_lego.common.handle_action import HandleAction
from ui_library.page.student import login, home
from ui_library.common.read_config import readconfig
from ui_auto_lego.common.launch import InitMobilStartApp
from ui_library.logic.student.login_logic import LoginLogic
from ui_library.page.common.sys import Android_Sys
import time
obj_handle_action = HandleAction()
obj_login_page = login.Login()
obj_home_page = home.Home()
obj_rf_config = readconfig()
obj_login_logic = LoginLogic()
obj_user_info = eval(obj_rf_config.study_user)
obj_sys_page = Android_Sys()
@allure.feature('ViSpark Study 登录前及登录测试')
class TestLogin(object):
init_mobile_start_app = InitMobilStartApp()
poco_driver = init_mobile_start_app.poco_driver
def setup(self):
# 启动被测试应用
self.init_mobile_start_app.init_app()
pass
def teardown(self):
# 退出被测试应用并清理数据
self.init_mobile_start_app.quit()
self.init_mobile_start_app.clear_app()
pass
@allure.title("已存在账号密码登录")
def test_login(self):
obj_login_logic.login_app_by_pwd(self.poco_driver, obj_user_info.get("username"), obj_user_info.get("password"),
obj_user_info.get("nickname"))
obj_handle_action.find_element_by_poco(self.poco_driver, obj_home_page.get_headers_star())
text = obj_handle_action.get_text_by_poco(self.poco_driver, obj_home_page.get_headers_star())
str = "2040"
assert str in text
if __name__ == '__main__':
A= TestLogin()
A.test_login()

View File

@@ -0,0 +1,95 @@
# -*- coding: utf-8 -*-
# __author__ = 'luozhipeng'
from airtest.core.api import *
import allure
from ui_auto_lego.common.handle_action import HandleAction
from ui_auto_lego.common.handle_driver import HandleDriver
from ui_library.page.student import login, home,schedule,homework,assessment,setting
from ui_library.common.read_config import readconfig
from ui_auto_lego.common.launch import InitMobilStartApp
from ui_library.logic.student.login_logic import LoginLogic
from ui_library.logic.student.home_logic import HomeLogic
obj_handle_action = HandleAction()
obj_handle_driver = HandleDriver()
obj_login_page = login.Login()
obj_home_page = home.Home()
obj_homework_page = homework.Homework()
obj_assessment_page = assessment.Assessment()
obj_setting_page = setting.Setting()
obj_schedule_page = schedule.Schedule()
obj_rf_config = readconfig()
obj_login_logic = LoginLogic()
obj_home_logic = HomeLogic()
obj_user_info = eval(obj_rf_config.study_user)
@allure.feature('ViSpark Study 设置页测试')
class TestSetting(object):
init_mobile_start_app = InitMobilStartApp()
poco_driver = init_mobile_start_app.poco_driver
def setup(self):
# 启动被测试应用
# self.init_mobile_start_app.launch_app()
# obj_home_logic.click_home_setting(poco=self.poco_driver)
pass
def teardown(self):
# 退出被测试应用并清理数据
pass
# self.init_mobile_start_app.quit()
# self.init_mobile_start_app.clear_app()
@allure.title("设置页修改个人信息")
def test_setting_info(self):
# with allure.step("点击昵称修改按钮"):
# obj_handle_action.click_by_poco(self.poco_driver,obj_setting_page.get_change_nickname_button())
# assert obj_handle_action.is_exists_by_poco(self.poco_driver,obj_setting_page.get_setting_student_profile_title())
#
# with allure.step("输入修改昵称"):
# ui_auto_nickname_empty = ''
# ui_auto_nickname = "UiAutoNickName"
# obj_handle_action.set_text_by_poco(self.poco_driver, obj_setting_page.get_setting_student_profile_nickname_input(),
# ui_auto_nickname)
# with allure.step("点击保存"):
# obj_handle_action.click_by_poco(self.poco_driver, obj_setting_page.get_setting_student_profile_save_button())
# assert obj_handle_action.is_exists_by_poco(self.poco_driver,
# obj_setting_page.get_setting_title())
# birth = obj_handle_action.get_text_by_poco(self.poco_driver,
# obj_setting_page.get_change_date_of_birth_button())
# print(birth)
# with allure.step("点击修改生日"):
#
# obj_handle_action.click_by_poco(self.poco_driver,
# obj_setting_page.get_change_date_of_birth_button())
# obj_handle_action.click_by_poco(self.poco_driver,
# obj_setting_page.get_setting_student_profile_calendar())
#
# if birth != "07/2022":
# obj_handle_action.swipe_by_poco(self.poco_driver, element=obj_setting_page.get_setting_calendar_year_up(), direction="up",duration=0.2)
# obj_handle_action.swipe_by_poco(self.poco_driver, element=obj_setting_page.get_setting_calendar_month_under(),
# direction="up",duration=0.2)
# else:
# obj_handle_action.swipe_by_poco(self.poco_driver, element=obj_setting_page.get_setting_calendar_year_up(), direction="down",duration=0.2)
# obj_handle_action.swipe_by_poco(self.poco_driver, element=obj_setting_page.get_setting_calendar_month_under(),
# direction="down",duration=0.2)
obj_handle_action.click_by_poco(self.poco_driver,obj_setting_page.get_setting_calendar_sure_button())
assert obj_handle_action.is_exists_by_poco(self.poco_driver,
obj_setting_page.get_setting_student_profile_title())
with allure.step("点击保存"):
obj_handle_action.click_by_poco(self.poco_driver, obj_setting_page.get_setting_student_profile_save_button())
assert obj_handle_action.is_exists_by_poco(self.poco_driver,
obj_setting_page.get_setting_title())
# birth_2 = obj_handle_action.get_text_by_poco(self.poco_driver,
# obj_setting_page.get_change_date_of_birth_button())
# print(birth_2)
# assert birth_2 != birth
# with allure.step("点击关闭个人信息页按钮"):
# obj_handle_action.click_by_poco(self.poco_driver, obj_setting_page.get_setting_student_profile_close_location())
# assert obj_handle_action.is_exists_by_poco(self.poco_driver,
# obj_setting_page.get_setting_title())