当前位置: 首页 > news >正文

食源送系统项目的测试

一、对整个系统编写测试用例

        功能测试

        

       

        性能测试

                兼容性测试

                易用性测试

 

        安全测试

二、接口测试

        针对接口的功能测试,也就是检验接口是否按照接口文档输入输出

        2.1 使用Postman发送HTTP请求

        

        2.2 使用Java + TestNG 编写自动化测试用例

                登录界面功能

package com.sky.test;import org.junit.jupiter.api.Order;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;import java.util.concurrent.TimeUnit;
public class LoginAndOut {public  static WebDriver driver;@BeforeClass@Order(1)public void openBrowser(){System.setProperty("webdriver.edge.driver" , "D:/EdgeDriver/msedgedriver.exe");//打开浏览器EdgeOptions options = new EdgeOptions();options.addArguments("--remote-allow-origins=*");driver = new EdgeDriver(options);System.out.println(driver);driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);}/*** 登录,登出* @throws InterruptedException*/@org.testng.annotations.Test@Order(2)public void Login() throws InterruptedException {
//        driver = new E;driver.get("http://www.localhost:81");driver.manage().window().maximize();driver.findElement(By.xpath("//input[@placeholder='账号']")).clear();driver.findElement(By.xpath("//input[@placeholder='账号']")).sendKeys("admin");Thread.sleep(1000);driver.findElement(By.xpath("//input[@placeholder='密码']")).clear();driver.findElement(By.xpath("//input[@placeholder='密码']")).sendKeys("123456");Thread.sleep(1000);driver.findElement(By.xpath("//span[text()='登录']")).click();Thread.sleep(1000);driver.findElement(By.xpath("/html/body/div[2]/div/div[2]")).click();driver.findElement(By.xpath("//span[contains(text(),'管理员')]")).click();Thread.sleep(2000);driver.findElement(By.xpath("//div[@class='userList']/p[@class='outLogin']")).click();Thread.sleep(1000);driver.findElement(By.xpath("//span[text()='登录']")).click();}}

        添加菜品功能

package com.sky.test;
import net.sf.jsqlparser.statement.select.KSQLWindow;
import org.junit.jupiter.api.Order;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.edge.EdgeDriver;import org.openqa.selenium.edge.EdgeOptions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;import java.util.concurrent.TimeUnit;public class homepage {public WebDriver driver;@BeforeClasspublic void openBrowser() {driver = LoginAndOut.driver;}/*** 登录-菜品管理-添加菜品*/@Test@Order(3)public void saveDish() throws InterruptedException {driver.findElement(By.xpath("//div/a[@href='#/dish']")).click();driver.findElement(By.xpath("//*[@id=\"app\"]/div/div[2]/section/div/div/div[1]/div[4]/button/span")).click();driver.findElement(By.xpath("//input[@placeholder='请填写菜品名称']")).clear();Thread.sleep(1000);driver.findElement(By.xpath("//input[@placeholder='请填写菜品名称']")).sendKeys("selenium");driver.findElement(By.xpath("//input[@placeholder='请设置菜品价格']")).clear();Thread.sleep(1000);driver.findElement(By.xpath("//input[@placeholder='请设置菜品价格']")).sendKeys("888");driver.findElement(By.xpath("//input[@placeholder='请选择菜品分类']")).click();Thread.sleep(1000);WebElement element = driver.findElement(By.xpath("//ul[@class='el-scrollbar__view el-select-dropdown__list']"));driver.findElement(By.xpath("//ul[@class='el-scrollbar__view el-select-dropdown__list']/li/span")).click();driver.findElement(By.xpath("//span[@class='addBut']")).click();driver.findElement(By.xpath("//input[@placeholder='请选择口味']")).click();driver.findElement(By.xpath("//input[@name='file']")).sendKeys("C:\\Users\\FK\\Desktop\\HTML+CSS+JavaScript\\fengjing1.jpg");driver.findElement(By.xpath("//textarea")).sendKeys("haochi");driver.findElement(By.xpath("//span[contains(text(), '保存')]")).click();}}

        生成对应类的xml文件,指定每个test(测试类)的执行顺序,顺序完成操作

http://www.lryc.cn/news/412587.html

相关文章:

  • JS解构赋值
  • 多多OJ评测系统 前端项目环境初始化 安装Vue脚手架 引入Arco Design组件
  • OceanBase 配置项系统变量实现及应用详解(4):新增系统变量
  • `CAUTION: request is not finished yet!`
  • 科研绘图系列:R语言GWAS曼哈顿图(Manhattan plot)
  • DjangoRF-11-创建testcases子应用--任务模块
  • 服务器数据恢复—SAN环境下LUN被重复映射导致写操作不互斥的数据恢复案例
  • Linux系统安全加固:从防火墙到SELinux策略
  • 排序算法:归并排序,golang实现
  • CSS 的工作原理
  • 买完就后悔?只需几步教你 Apple 怎么申请退款
  • 【保卫战】休闲小游戏 链游
  • 如何构建自己的交易机器人开发环境
  • 解决WordPress文章引用的图片不显示问题
  • 商业银行国际结算规模创新高,合合信息AI助力金融行业智能处理多版式文档
  • 数字芯片设计验证经验分享:将ASIC IP核移植到FPGA上——更新概念并推动改变以完成充满挑战的任务!
  • 【Linux】Linux下的日志(日常级)
  • 手把手教你如何在Linux上轻松安装Python,告别编程入门难题
  • XSS-labs靶场(超详解)1-20关——附原码
  • 【网络安全】LockBit病毒入侵揭秘:如何防范与应对
  • 《开源大模型食用指南》适合中国宝宝的部署教程,基于Linux环境快速部署开源大模型
  • 体验教程:通义灵码陪你备战求职季
  • (070)爬楼梯
  • el-table 表格序号列前端实现递增,切换分页不从头开始
  • NSSCTF-Web题目27(Nginx漏洞、php伪协议、php解析绕过)
  • 分割损失:Dice vs. IoU
  • SpringBoot整合Juint,ssm框架
  • 基于supervisor制作基于环境变量配置的redis
  • 动态规划part01 509. 斐波那契数 70. 爬楼梯 746. 使用最小花费爬楼梯
  • CSS实现图片边框酷炫效果