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