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,8 @@
import os
import sys
BASIC_PATH = os.path.dirname(os.path.abspath(__file__))
# sys.path.append(BASIC_PATH)
PROJECT_PATH = os.path.abspath(os.path.join(BASIC_PATH, '../../../../../../'))
BAS_PATH = os.path.abspath(os.path.join(BASIC_PATH, '../../../../../../{}'.format("UBRD")))
sys.path.append(PROJECT_PATH)
sys.path.append(BAS_PATH)

View File

@@ -0,0 +1,123 @@
import { AndroidAgent, AndroidDevice, getConnectedDevices } from '@midscene/android';
import * as dotenv from 'dotenv';
import { expect } from 'vitest';
import { execSync } from 'child_process';
// 加载环境变量
dotenv.config();
// 设置环境变量
process.env.OPENAI_API_KEY = "fd86bcee-d77a-4299-b4c5-6f2c5c204d9c";
process.env.MIDSCENE_MODEL_NAME = "doubao-1.5-ui-tars-250328";
process.env.MIDSCENE_USE_VLM_UI_TARS = "DOUBAO";
process.env.OPENAI_BASE_URL = "https://ark.cn-beijing.volces.com/api/v3";
const sleep = (ms: number): Promise<void> => new Promise((r) => setTimeout(r, ms));
async function main() {
console.log('Starting test...');
try {
console.log('Getting connected devices...');
const devices = await getConnectedDevices();
console.log('Found devices:', devices);
const page = new AndroidDevice(devices[0].udid);
console.log('Created AndroidDevice instance');
// 👀 初始化 Midscene agent
console.log('Initializing AndroidAgent...');
const agent = new AndroidAgent(page, {
aiActionContext:
'如果出现位置、权限、用户协议等弹窗,点击同意。如果出现登录页面,关闭它。'
});
console.log('AndroidAgent initialized');
console.log('Connecting to device...');
await page.connect();
console.log('Connected to device');
// 强制设置横屏
console.log('Setting landscape orientation...');
try {
execSync(`adb -s ${devices[0].udid} shell settings put system accelerometer_rotation 0`);
execSync(`adb -s ${devices[0].udid} shell settings put system user_rotation 1`);
await sleep(2000);
// 检查屏幕方向
const orientation = execSync(`adb -s ${devices[0].udid} shell dumpsys input | grep 'SurfaceOrientation'`).toString();
console.log('Current orientation:', orientation);
if (!orientation.includes('SurfaceOrientation: 1')) {
console.log('Retrying to set landscape orientation...');
execSync(`adb -s ${devices[0].udid} shell settings put system user_rotation 1`);
await sleep(3000);
}
} catch (error) {
console.error('Error setting orientation:', error);
}
// 先强制停止应用,清除缓存
console.log('Force stopping app...');
try {
// 使用adb命令停止应用
console.log('Stopping app...');
execSync(`adb -s ${devices[0].udid} shell am force-stop cn.huohua.edustudent`);
await sleep(2000);
// 使用adb命令清除应用数据
console.log('Clearing app data...');
execSync(`adb -s ${devices[0].udid} shell pm clear cn.huohua.edustudent`);
await sleep(2000);
console.log('App stopped and cleared');
} catch (error) {
console.error('Error executing commands:', error);
}
// 启动应用到指定页面
console.log('Launching app...');
try {
console.log('Attempting to launch app using aiAction...');
await agent.aiAction('启动火花思维学生端app');
console.log('aiAction completed successfully');
await sleep(5000); // 增加等待时间,确保应用完全启动
// 处理权限和协议弹窗
await agent.aiAction('我在一个横屏显示的用户协议弹窗中。这个弹窗有一个标题"用户注册协议与隐私政策",在弹窗底部有两个按钮。右边的按钮是"同意并使用"它是一个蓝色的TextView按钮resource-id是"cn.huohua.edustudent:id/btn_yes"。请点击这个"同意并使用"按钮。注意:屏幕是横向旋转的。');
await sleep(5000);
// 切换到密码登录
await agent.aiAction('在屏幕上查找"密码登录"标签或按钮,通常在登录界面顶部。点击它切换到密码登录模式。');
await sleep(2000);
// 输入手机号
await agent.aiAction('在屏幕上查找手机号输入框,它通常显示"请输入手机号"的提示文字。点击输入框,然后输入: 18202810506');
await sleep(2000);
// 输入密码
await agent.aiAction('在屏幕上查找密码输入框,它通常显示"请输入密码"的提示文字。点击输入框,然后输入: A123456');
await sleep(2000);
// 勾选协议
await agent.aiAction('在屏幕底部查找用户协议勾选框,它通常是一个小方框,旁边有"我已阅读并同意"的文字。如果没有被勾选,点击它来勾选。');
await sleep(2000);
// 点击登录
await agent.aiAction('在屏幕上查找"登录"或"立即登录"按钮,它通常是一个醒目的大按钮,位于输入框下方。点击这个按钮。');
await sleep(2000);
} catch (error) {
console.error('Error during app launch:', error);
throw error;
}
console.log('App launched');
} catch (error) {
console.error('Error occurred:', error);
throw error;
}
}
// 运行主函数
main().catch(console.error);

View File

@@ -0,0 +1,4 @@
# -*- coding:utf-8 -*-
# @Time : 2023/7/7 13:37
# @Author: luozhipeng
# @File : __init__.py.py

View File

@@ -0,0 +1,228 @@
# -*- coding:utf-8 -*-
from airtest.core.api import *
import allure
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 ui_library.page.student.huohua.PC.home.huohua_pc_home import HuohuaPCHome
from ui_library.page.student.huohua.PC.login.huohua_pc_login import HuohuaPCLogin
from library.CommonFun.host_update import HostUpdate,CoreApollo
from base_framework.public_tools.edu_user_helper import EDUUserHelper
from ui_library.page.student.huohua.PC.classroom.huohua_pc_classroom import HuohuaPCClassroom
import subprocess
import logging
import shutil
logger = logging.getLogger("airtest")
logger.setLevel(logging.ERROR)
host_update = HostUpdate()
obj_edu_user_helper = EDUUserHelper()
obj_core_apollo = CoreApollo()
@allure.feature('Huohua Student')
class TestHuohuaStudentLogin:
def setup(self):
self.host_list = []
file_path = r"C:\Users\Administrator\AppData\Roaming\peppa-app-pc-student-sim\db.json"
source_file = r"C:\Users\Administrator\AppData\Roaming\st-huohua\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\\peppa-app-pc-student-sim\\火花思维 - SIM版.exe'])
sleep(15)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维学生端*"])
defalut_status = HuohuaPCHome().get_defalut_status()
if not defalut_status :
HuohuaPCHome().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', '火花思维 - SIM版.exe'])
@allure.title("[国内学生端PC前端登录域名降级--001]")
def test_student_login_by_pwd_low_fe(self):
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维学生端*"])
with allure.step("清理客户端缓存"):
file_path = r"C:\Users\Administrator\AppData\Roaming\peppa-app-pc-student-sim\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
# with allure.step("点击用户默认头像"):
# HuohuaPCHome().click_defult_avatar()
with allure.step("清除前端缓存"):
View().input_console_command("window.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("点击通过密码登录"):
HuohuaPCLogin().click_by_pwd()
with allure.step("输入手机号"):
HuohuaPCLogin().input_phone("12345678001")
with allure.step("点击同意协议"):
HuohuaPCLogin().click_agree_label()
with allure.step("输入密码"):
HuohuaPCLogin().input_pwd("123456")
with allure.step("点击登录按钮"):
HuohuaPCLogin().click_login_button()
sleep(25)
#with allure.step("校验网络异常"):
# HuohuaPCLogin().assert_login_network_error()
with allure.step("点击登录按钮"):
default_status = HuohuaPCLogin().get_login_button()
if default_status:
HuohuaPCLogin().click_login_button()
sleep(25)
else:
print("已经登录进去了")
#with allure.step("校验网络异常"):
# HuohuaPCLogin().assert_login_network_error()
with allure.step("点击登录按钮"):
default_status = HuohuaPCLogin().get_login_button()
if default_status:
HuohuaPCLogin().click_login_button()
else:
print("已经登录进去了")
@allure.title("[国内学生端PC前端腾讯验证码降级--002]")
def test_student_login_by_pwd_low_ten(self):
with allure.step("添加验证码域名屏蔽并清理客户端缓存"):
self.host_list = [{"ip": "0.0.0.0", "host_name": "turing.captcha.qcloud.com"}]
host_update.host_update_by_host_dict(self.host_list)
host_update.wait_dns_flush(ip="0.0.0.0" ,domain= "turing.captcha.qcloud.com")
file_path = r"C:\Users\Administrator\AppData\Roaming\peppa-app-pc-student-sim\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', '火花思维 - SIM版.exe'])
subprocess.Popen(
['C:\\Users\\Administrator\\AppData\\Local\\Programs\\peppa-app-pc-student-sim\\火花思维 - SIM版.exe'])
sleep(15)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维学生端*"])
defalut_status = HuohuaPCHome().get_defalut_status()
if not defalut_status:
HuohuaPCHome().login_out()
with allure.step("输入手机号"):
HuohuaPCLogin().input_phone("13460219197")
with allure.step("点击同意协议"):
HuohuaPCLogin().click_agree_label()
with allure.step("点击获取验证码"):
HuohuaPCLogin().click_get_code()
with allure.step("确认存在图形验证码的验证按钮"):
HuohuaPCLogin().assert_login_low_button()
@allure.title("[国内学生端PC前端腾讯验证码正常弹出--003]")
def test_student_login_by_pwd_ten(self):
with allure.step("清除客户端缓存"):
file_path = r"C:\Users\Administrator\AppData\Roaming\peppa-app-pc-student-sim\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', '火花思维 - SIM版.exe'])
subprocess.Popen(
['C:\\Users\\Administrator\\AppData\\Local\\Programs\\peppa-app-pc-student-sim\\火花思维 - SIM版.exe'])
sleep(15)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维学生端*"])
with allure.step("点击用户默认头像"):
HuohuaPCHome().click_defult_avatar()
with allure.step("输入手机号"):
HuohuaPCLogin().input_phone("13460219197")
with allure.step("点击同意协议"):
HuohuaPCLogin().click_agree_label()
with allure.step("点击获取验证码"):
HuohuaPCLogin().click_get_code()
with allure.step("确认存在腾讯验证码的滑动按钮"):
HuohuaPCLogin().assert_login_tencent_image()
@allure.title("[国内学生端PC磐石登录成功--004]")
def test_student_login_by_pwd_normal(self):
with allure.step("清除客户端缓存"):
file_path = r"C:\Users\Administrator\AppData\Roaming\peppa-app-pc-student-sim\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', '火花思维 - SIM版.exe'])
subprocess.Popen(
['C:\\Users\\Administrator\\AppData\\Local\\Programs\\peppa-app-pc-student-sim\\火花思维 - SIM版.exe'])
sleep(15)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维学生端*"])
with allure.step("清除前端缓存"):
View().input_console_command("window.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("点击用户默认头像"):
HuohuaPCHome().click_defult_avatar()
with allure.step("点击通过密码登录"):
HuohuaPCLogin().click_by_pwd()
with allure.step("输入手机号"):
HuohuaPCLogin().input_phone("13460219197")
with allure.step("点击同意协议"):
HuohuaPCLogin().click_agree_label()
with allure.step("输入密码"):
HuohuaPCLogin().input_pwd("123456")
with allure.step("点击登录按钮"):
HuohuaPCLogin().click_login_button()
sleep(20)
with allure.step("确认登录成功"):
HuohuaPCHome().assert_discover_button()
@allure.title("[国内学生端PCcheck备份域名强制登录进入课堂上课--005]")
def test_student_login_by_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\peppa-app-pc-student-sim\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', '火花思维 - SIM版.exe'])
subprocess.Popen(
['C:\\Users\\Administrator\\AppData\\Local\\Programs\\peppa-app-pc-student-sim\\火花思维 - SIM版.exe'])
sleep(15)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维学生端*"])
defalut_status = HuohuaPCHome().get_defalut_status()
if not defalut_status:
HuohuaPCHome().login_out()
with allure.step("清除前端缓存"):
View().input_console_command("window.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
sleep(2)
with allure.step("输入手机号"):
HuohuaPCLogin().input_phone("15890630602")
with allure.step("点击同意协议"):
HuohuaPCLogin().click_agree_label()
with allure.step("点击获取验证码按钮"):
HuohuaPCLogin().click_get_code()
with allure.step("确认存在验证码提示"):
HuohuaPCLogin().assert_login_force_code_image()
sleep(2)
with allure.step("点击通过密码登录"):
HuohuaPCLogin().click_by_pwd()
with allure.step("输入手机号"):
HuohuaPCLogin().input_phone("15890630602")
with allure.step("输入密码"):
HuohuaPCLogin().input_pwd("123456")
# with allure.step("点击登录按钮"):
# HuohuaPCLogin().click_login_button()
# with allure.step("确认存在密码异常提示"):
# HuohuaPCLogin().assert_login_force_pwd_image()
# sleep(2)
sleep(2)
with allure.step("点击通过验证登录"):
HuohuaPCLogin().click_by_code()
with allure.step("输入验证码"):
HuohuaPCLogin().input_code("8888")
with allure.step("点击登录按钮"):
HuohuaPCLogin().click_login_button()
sleep(5)
with allure.step("点击进入课堂按钮"):
HuohuaPCHome().click_enter_classroom()
sleep(120)
with allure.step("成功进入课堂"):
HuohuaPCClassroom.check_classroom_icon()
if __name__ == '__main__':
TestHuohuaStudentLogin().test_student_login_by_pwd_low_ten()

View File

@@ -0,0 +1,231 @@
# -*- coding:utf-8 -*-
from airtest.core.api import *
import allure
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 ui_library.page.student.huohua.PC.home.huohua_pc_home import HuohuaPCHome
from ui_library.page.student.huohua.PC.login.huohua_pc_login import HuohuaPCLogin
from library.CommonFun.host_update import HostUpdate,CoreApollo
from base_framework.public_tools.edu_user_helper import EDUUserHelper
from ui_library.page.student.huohua.PC.classroom.huohua_pc_classroom import HuohuaPCClassroom
import subprocess
import logging
import shutil
logger = logging.getLogger("airtest")
logger.setLevel(logging.ERROR)
host_update = HostUpdate()
obj_edu_user_helper = EDUUserHelper()
obj_core_apollo = CoreApollo()
import time
def assert_with_retry(assertion_func, retries=5, delay=1):
found = False
for i in range(retries):
try:
assertion_func()
found = True
return # If the assertion_func() call doesn't raise an exception, exit the function
except AssertionError:
if i < retries - 1: # If this isn't the last retry
time.sleep(delay) # Wait for a while before retrying
if not found:
raise Exception("Network error message not found after n attempts")
@allure.feature('Huohua Student Online')
class TestHuohuaStudentLogin:
def setup(self):
self.host_list = []
file_path = r"C:\Users\Administrator\AppData\Roaming\huohua-learner-client\db.json"
source_file = r"C:\Users\Administrator\AppData\Roaming\on_huohua\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\\huohua-learner-client\\火花思维.exe'])
sleep(15)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维学生端*"])
defalut_status = HuohuaPCHome().get_defalut_status()
if not defalut_status :
HuohuaPCHome().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', '火花思维.exe'])
@allure.title("[国内学生端PC前端登录域名降级--001]")
def test_student_login_by_pwd_low_fe(self):
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维学生端*"])
with allure.step("清理客户端缓存"):
file_path = r"C:\Users\Administrator\AppData\Roaming\huohua-learner-client\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
#with allure.step("点击用户默认头像"):
# HuohuaPCHome().click_defult_avatar()
with allure.step("清除前端缓存 域名重新轮询"):
View().input_console_command("window.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("点击通过密码登录"):
HuohuaPCLogin().click_by_pwd()
with allure.step("输入手机号"):
HuohuaPCLogin().input_phone("12345678001")
with allure.step("点击同意协议"):
HuohuaPCLogin().click_agree_label()
with allure.step("输入密码"):
HuohuaPCLogin().input_pwd("123456")
sleep(2)
with allure.step("第一次点击登录按钮"):
HuohuaPCLogin().click_login_button()
sleep(5)
with allure.step("第二次点击登录按钮"):
HuohuaPCLogin().get_login_button()
sleep(10)
with allure.step("第三次点击登录按钮"):
HuohuaPCLogin().get_login_button()
sleep(10)
with allure.step("第四次点击登录按钮"):
default_status = HuohuaPCLogin().get_login_button()
if default_status:
HuohuaPCLogin().click_login_button()
sleep(10)
else:
print("已经登录进去了")
@allure.title("[国内学生端PC前端腾讯验证码降级--002]")
def test_student_login_by_pwd_low_ten(self):
with allure.step("添加验证码域名屏蔽并清理客户端缓存"):
self.host_list = [{"ip": "0.0.0.0", "host_name": "turing.captcha.qcloud.com"}]
host_update.host_update_by_host_dict(self.host_list)
host_update.wait_dns_flush(ip="0.0.0.0" ,domain= "turing.captcha.qcloud.com")
file_path = r"C:\Users\Administrator\AppData\Roaming\huohua-learner-client\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', '火花思维.exe'])
subprocess.Popen(
['C:\\Users\\Administrator\\AppData\\Local\\Programs\\huohua-learner-client\\火花思维.exe'])
sleep(10)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维学生端*"])
defalut_status = HuohuaPCHome().get_defalut_status()
if not defalut_status:
HuohuaPCHome().login_out()
# with allure.step("点击用户默认头像"):
# HuohuaPCHome().click_defult_avatar()
with allure.step("输入手机号"):
HuohuaPCLogin().input_phone("18333586570")
with allure.step("点击同意协议"):
HuohuaPCLogin().click_agree_label()
with allure.step("点击获取验证码"):
HuohuaPCLogin().click_get_code()
with allure.step("确认存在图形验证码的验证按钮"):
HuohuaPCLogin().assert_login_low_button()
@allure.title("[国内学生端PC前端腾讯验证码正常弹出--003]")
def test_student_login_by_pwd_ten(self):
with allure.step("清除客户端缓存"):
file_path = r"C:\Users\Administrator\AppData\Roaming\huohua-learner-client\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', '火花思维.exe'])
subprocess.Popen(
['C:\\Users\\Administrator\\AppData\\Local\\Programs\\huohua-learner-client\\火花思维.exe'])
sleep(10)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维学生端*"])
defalut_status = HuohuaPCHome().get_defalut_status()
if not defalut_status:
HuohuaPCHome().login_out()
#with allure.step("点击用户默认头像"):
# HuohuaPCHome().click_defult_avatar()
with allure.step("点击同意协议"):
HuohuaPCLogin().click_agree_label()
with allure.step("输入手机号"):
HuohuaPCLogin().input_phone("18333586570")
with allure.step("点击获取验证码"):
HuohuaPCLogin().click_get_code()
with allure.step("确认存在腾讯验证码的滑动按钮"):
HuohuaPCLogin().assert_login_tencent_image()
@allure.title("[国内学生端PC磐石登录成功--004]")
def test_student_login_by_pwd_normal(self):
with allure.step("清除客户端缓存"):
file_path = r"C:\Users\Administrator\AppData\Roaming\huohua-learner-client\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', '火花思维.exe'])
subprocess.Popen(
['C:\\Users\\Administrator\\AppData\\Local\\Programs\\huohua-learner-client\\火花思维.exe'])
sleep(10)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维学生端*"])
defalut_status = HuohuaPCHome().get_defalut_status()
if not defalut_status:
HuohuaPCHome().login_out()
with allure.step("清除前端缓存"):
View().input_console_command("window.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("点击用户默认头像"):
HuohuaPCHome().click_defult_avatar()
with allure.step("点击通过密码登录"):
HuohuaPCLogin().click_by_pwd()
with allure.step("输入手机号"):
HuohuaPCLogin().input_phone("18333586570")
with allure.step("点击同意协议"):
HuohuaPCLogin().click_agree_label()
with allure.step("输入密码"):
HuohuaPCLogin().input_pwd("123456")
with allure.step("点击登录按钮"):
HuohuaPCLogin().click_login_button()
sleep(10)
with allure.step("确认登录成功"):
HuohuaPCHome().assert_discover_button()
@allure.title("[国内学生端PCcheck备份域名强制登录进入课堂上课--005]")
def test_student_login_by_check(self):
with allure.step("添加域名重定向到降级域名"):
self.host_list = [{"ip": "127.0.0.1", "host_name": "core-api.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.huohua.cn")
file_path = r"C:\Users\Administrator\AppData\Roaming\huohua-learner-client\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', '火花思维.exe'])
subprocess.Popen(
['C:\\Users\\Administrator\\AppData\\Local\\Programs\\huohua-learner-client\\火花思维.exe'])
sleep(10)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维学生端*"])
defalut_status = HuohuaPCHome().get_defalut_status()
if not defalut_status:
HuohuaPCHome().login_out()
with allure.step("清除前端缓存"):
View().input_console_command("window.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("点击用户默认头像"):
HuohuaPCHome().click_defult_avatar()
#with allure.step("点击通过验证登录"):
# HuohuaPCLogin().click_by_code()
with allure.step("点击同意协议"):
HuohuaPCLogin().click_agree_label()
with allure.step("输入手机号"):
HuohuaPCLogin().input_phone("15890630602")
with allure.step("输入验证码"):
HuohuaPCLogin().input_code("8888")
with allure.step("点击登录按钮"):
HuohuaPCLogin().click_login_button()
sleep(5)
with allure.step("点击进入课堂按钮"):
HuohuaPCHome().click_enter_classroom()
sleep(100)
with allure.step("成功进入课堂"):
HuohuaPCClassroom.check_classroom_icon()
if __name__ == '__main__':
TestHuohuaStudentLogin().test_student_login_by_pwd_low_ten()

View File

@@ -0,0 +1,4 @@
# -*- coding:utf-8 -*-
# @Time : 2023/7/7 13:37
# @Author: luozhipeng
# @File : __init__.py.py

View File

@@ -0,0 +1,75 @@
import allure
from ui_auto_lego.common.handle_action import HandleAction
from ui_library.page.student.huohua import login, home,setting,profile
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
import time
obj_handle_action = HandleAction()
obj_login_page = login.Edu_Huo_Hua_Login()
obj_home_page = home.Edu_Huo_Hua_Home()
obj_profile_page = profile.Edu_Huo_Hua_Profile()
obj_set_page = setting.Edu_Huo_Hua_Set()
obj_rf_config = readconfig()
obj_login_logic = LoginLogic()
obj_user_info = eval(obj_rf_config.study_user)
@allure.feature('huohua 登录前及登录测试')
class TestLogin(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_setting_info(self):
with allure.step("点击设置项"):
poco = self.poco_driver
for i in range(1, 100):
# obj_handle_action.click_by_poco(poco, obj_home_page.get_reload())
# time.sleep(3)
obj_handle_action.click_by_poco(poco, obj_home_page.get_setiing_menu())
obj_handle_action.click_by_poco(poco, obj_set_page.get_logout_menu())
obj_handle_action.click_by_poco(poco, obj_home_page.get_setiing_menu())
obj_handle_action.click_by_poco(poco, obj_login_page.get_on_default_phone())
obj_handle_action.click_by_poco(poco, obj_login_page.get_pwd_login_menu())
obj_handle_action.click_by_poco(poco, obj_login_page.get_agree_label())
obj_handle_action.set_text_by_poco(poco, obj_login_page.get_phone_insert(), 12345678001)
obj_handle_action.set_text_by_poco(poco, obj_login_page.get_pwd_insert(), 123456)
obj_handle_action.click_by_poco(poco, obj_login_page.get_login_button())
# obj_handle_action.click_by_poco(poco, obj_home_page.get_reload())
# time.sleep(3)
obj_handle_action.click_by_poco(poco, obj_home_page.get_profile_photo_menu())
obj_handle_action.click_by_poco(poco, obj_profile_page.get_Profile_logout_menu())
obj_handle_action.click_by_poco(poco, obj_home_page.get_profile_photo_menu())
obj_handle_action.click_by_poco(poco, obj_login_page.get_on_default_phone())
obj_handle_action.click_by_poco(poco, obj_login_page.get_pwd_login_menu())
obj_handle_action.click_by_poco(poco, obj_login_page.get_agree_label())
obj_handle_action.set_text_by_poco(poco, obj_login_page.get_phone_insert(), 12345678001)
obj_handle_action.set_text_by_poco(poco, obj_login_page.get_pwd_insert(), 123456)
obj_handle_action.click_by_poco(poco, obj_login_page.get_login_button())
# obj_handle_action.click_by_poco(poco, obj_home_page.get_reload())
if __name__ == '__main__':
A= TestLogin()
for i in range(1,100):
A.test_setting_info()

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())