一、源码,c_page.py
''' @Date:2022/11/14 14:36 @Author:一加一 ''' import streamlit as st import os import sys BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(BASE_DIR) from testcase.test_cc import * import pytest from tools.operate_config import OperateConfig class TestPage: # 实例化对象 getCjson = GetcJson(None) # 实例化对象,获取业务系统C的json数据,即接口请求body side = ["C系统"] st.sidebar.title("使用左侧面板") system = st.sidebar.selectbox("请选择", side) env = ["QA1", "QA2"] testenv = st.sidebar.selectbox("请选择环境", env) if system == "C系统": script_list = ["查询客户","下订单"] script = st.selectbox("请选择脚本",script_list) if script == "查询客户": customer_name = st.text_input("请输入客户名称") submit = st.button("提交") if submit: # 将选择的环境set到config配置文件 OperateConfig().set_node_value('ENV', 'env', testenv) # 将客户名称set到json文件 getCjson.set_cuslist_customerName(customer_name) # 执行查询客户脚本 pytest.main(['E:\\02Api test\\XX_ApiTest\\testcase\\test_cc.py']) st.write("提交成功\n"+customer_name)
二、效果图
在文件所在目录下执行命令 streamlit run c_page.py,执行完后会生成一个url,可进入到如下页面
标签:set,script,接口,st,Pytest,path,import,Streamlit,os From: https://www.cnblogs.com/Chilam007/p/16927229.html