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

郑州的网站建设公司什么网站可以免费发广告

郑州的网站建设公司,什么网站可以免费发广告,做网站北京,wordpress备份如何安装目录 1.报告概要 2、测试环境 3、手动测试用例编写 4、自动化测试用例 1.报告概要 测试对象:基于SSM项目的博客系统。 测试目的:检测博客项目是否符合预期,并且对测试知识进行练习和巩固。 测试点:主要针对常用的功能进行测…

目录

1.报告概要

2、测试环境

3、手动测试用例编写

4、自动化测试用例


1.报告概要

测试对象:基于SSM项目的博客系统。

测试目的:检测博客项目是否符合预期,并且对测试知识进行练习和巩固。

测试点:主要针对常用的功能进行测试如:博客项目的注册、登录、博客列表页、博客编辑页、个人列表页、导航栏等进行测试。

测试结果及结论:测试的常用功能全部正常,测试注册页面的密码时,发现密码没有限制长度以及强度的限制。

2、测试环境

硬件:Lenovo Y7000 2020

软件:Windows 、Google Chrome、IDEA

测试工具:自动化测试工具Selenium3

浏览器版本:Google Chrome  118.0.5993.118

3、手动测试用例编写

用户注册页 

用户登录页 

个人列表页

博客列表页(主页)

 

博客详情页

博客编辑页

4、自动化测试用例

博客注册页面

package Blog;import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.openqa.selenium.By;import java.util.concurrent.TimeUnit;import static java.lang.Thread.sleep;
//根据程序员指定的顺序执行
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class RegCases extends InitAndEnd{/** 注册成功* */@Order(1)@ParameterizedTest@CsvSource({"zhangsan,12345,12345"})void regSuccess(String username,String password,String conPassword ) throws InterruptedException {//打开主页面webDriver.get("http://154.8.139.1:48080/login.html");webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);//找到注册按钮webDriver.findElement(By.cssSelector("body > div.nav > a:nth-child(5)")).click();webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);sleep(3000);//输入注册的用户名,密码webDriver.findElement(By.cssSelector("#username")).sendKeys(username);webDriver.findElement(By.cssSelector("#password")).sendKeys(password);webDriver.findElement(By.cssSelector("#password2")).sendKeys(conPassword);webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//点击提交webDriver.findElement(By.cssSelector("#submit")).click();sleep(3000);//处理弹窗String test = webDriver.switchTo().alert().getText();String except = "恭喜:注册成功!";webDriver.switchTo().alert().accept();Assertions.assertEquals(except,test);}/*** 用户名为空注册失败* */@Order(2)@ParameterizedTest@CsvSource(value = {"'',123,123","'',123,456","'',546,''","'','',456","'','',''","'张三','',''","'张三','123',''","'张三','123','123'",})void RegFail(String username,String password,String conPassword) throws InterruptedException {//打开主页webDriver.get("http://154.8.139.1:48080/login.html");webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);sleep(3000);//找到注册点击webDriver.findElement(By.cssSelector("body > div.nav > a:nth-child(5)")).click();webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//输入用户名、密码、确认密码webDriver.findElement(By.cssSelector("#username")).sendKeys(username);webDriver.findElement(By.cssSelector("#password")).sendKeys(password);webDriver.findElement(By.cssSelector("#password2")).sendKeys(conPassword);webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//点击提交webDriver.findElement(By.cssSelector("#submit")).click();webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);sleep(3000);//处理弹窗//获取弹窗信息String test = webDriver.switchTo().alert().getText();webDriver.switchTo().alert().accept();String except = "恭喜:注册成功!";//断言Assertions.assertNotEquals(except,test);}}

博客登录页面

import static java.lang.Thread.sleep;
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class BlogCases extends InitAndEnd{/** 输入正确的账号、密码登录成功* */@Order(1)@ParameterizedTest@CsvFileSource(resources = "LoginSuccess.csv")void LoginSuccess(String username,String password,String blog_list_url) throws InterruptedException {//打开博客登录页面webDriver.get("http://154.8.139.1:48080/login.html");webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);//输入账号adminwebDriver.findElement(By.cssSelector("#username")).sendKeys(username);webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);//输入密码123webDriver.findElement(By.cssSelector("#password")).sendKeys(password);webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);//点击提交按钮webDriver.findElement(By.cssSelector("#submit")).click();sleep(3000);//处理弹窗//用于接受警告对话框(确认)webDriver.switchTo().alert().accept();//跳转到列表页//获取到当前的页面的urlString cur_url = webDriver.getCurrentUrl();webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);//判断url是否和预期相等Assertions.assertEquals(blog_list_url,cur_url);}/** 输入错误的密码和账号* */@Disabled@Order(2)@ParameterizedTest@CsvSource(value = {"张帆,123","lisi,123","'',123456","张帆,''","'',''"})void LoginFail(String username,String password) throws InterruptedException {//打开博客登录页面webDriver.get("http://154.8.139.1:48080/login.html");webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//输入账号和密码webDriver.findElement(By.cssSelector("#username")).sendKeys(username);webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);webDriver.findElement(By.cssSelector("#password")).sendKeys(password);webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//点击提交按钮webDriver.findElement(By.cssSelector("#submit")).click();sleep(3000);//处理弹窗//获取弹窗内容String test = webDriver.switchTo().alert().getText();String except = "恭喜,登录成功!";//用于接受警告对话框(确认)webDriver.switchTo().alert().accept();//断言两个字符串的内容不相等,测试通过Assertions.assertNotEquals(except,test);System.out.println("登录不成功");}

个人列表页

    /** 博客列表页* */@Testvoid BlogList(){//打开博客列表页webDriver.get("http://154.8.139.1:48080/myblog_list.html");//获取页面上所有博客标题对应的元素webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);int title_num = webDriver.findElements(By.cssSelector("title")).size();//如果元素数量不为0,测试通过System.out.println(title_num);Assertions.assertNotEquals(0,title_num);}

博客详情页

   /** 博客详情页校验* url* 博客标题* 页面title是"博客详情页"* 用户名* 文章数* */@Order(4)@ParameterizedTest@MethodSource("Generator")void BlogDetail(String expect_url,String expected_title,String expected_blog_title,String except_username ) throws InterruptedException {//找到第一篇博客对应的查看全文按钮webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);webDriver.findElement(By.xpath("//*[@id=\"artListDiv\"]/div[1]/a[1]")).click();//获取当前页面的URLString cur_url = webDriver.getCurrentUrl();//获取当前页面的titleString cur_title = webDriver.getTitle();//获取博客标题webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);String cur_blog_title = webDriver.findElement(By.cssSelector("#title")).getText();webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);//获取用户名String cur_username = webDriver.findElement(By.cssSelector("#username")).getText();webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//获取文章数String cur_blog_count = webDriver.findElement(By.cssSelector("#artcount")).getText();webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);Assertions.assertEquals(except_username,cur_username);Assertions.assertNotEquals(0,cur_blog_count);if(cur_url.contains(expect_url)){System.out.println("测试通过");}else{System.out.println(cur_url);System.out.println("测试不通过");}Assertions.assertEquals(expected_title,cur_title);Assertions.assertEquals(expected_blog_title, cur_blog_title);}public class BlogCases extends InitAndEnd{public static Stream<Arguments> Generator() {return             Stream.of(Arguments.arguments("http://154.8.139.1:48080/blog_content.html","博客正文","自动化测试","张帆"));}

 博客编辑页,文章发布完成之后进入博客列表页检测发布文章的标题和时间。

    /** 博客编辑页* */@Order(5)@Testvoid EditBlog() throws InterruptedException {//打开博客列表页//webDriver.findElement(By.cssSelector("http://154.8.139.1:48080/myblog_list.html"));webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//找到写博客按钮,点击webDriver.findElement(By.cssSelector("body > div.nav > a:nth-child(5)")).click();webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//通过JS进行输入((JavascriptExecutor)webDriver).executeScript("document.getElementById(\"title\").value=\"自动化测试\"");sleep(3000);//点击发布webDriver.findElement(By.cssSelector("body > div.blog-edit-container > div.title > button")).click();sleep(3000);String cur_text = webDriver.switchTo().alert().getText();webDriver.switchTo().alert().dismiss();String except_text = "恭喜:添加成功!是否继续添加文章?";Assertions.assertEquals(except_text,cur_text);}/** 校验已发布博客标题* 校验已发布博客时间* */@Order(6)@Testvoid BlogInfoChecked(){webDriver.get("http://154.8.139.1:48080/blog_list.html");//获取第一篇博客标题String first_blog_title = webDriver.findElement(By.cssSelector("#artListDiv > div:nth-child(1) > div.title")).getText();//获取第一篇博客发布时间String first_blog_time= webDriver.findElement(By.cssSelector("#artListDiv > div:nth-child(1) > div.date")).getText();Assertions.assertEquals("自动化测试",first_blog_title);if(first_blog_time.contains("2023-11-02")){System.out.println("测试通过");}else{System.out.println("文章发布时间是:"+first_blog_time);System.out.println("测试不通过");}}

删除功能

    /** 测试博客列表页上删除功能* */@Order(7)@Testvoid DeleteCases() throws InterruptedException {//进入个人列表页webDriver.get("http://154.8.139.1:48080/myblog_list.html");webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//点击删除按钮webDriver.findElement(By.cssSelector("#artListDiv > div:nth-child(1) > a:nth-child(6)")).click();sleep(3000);String text = webDriver.switchTo().alert().getText();webDriver.switchTo().alert().accept();String except_text = "恭喜:删除成功";sleep(3000);String first_blog_title = webDriver.findElement(By.cssSelector("#artListDiv > div:nth-child(1) > div.title")).getText();webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);String except_title = "自动化测试";webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);Assertions.assertEquals(except_text,text);Assertions.assertEquals(first_blog_title,except_title);}

注销功能

    /** 注销功能测试* */@Order(8)@Testvoid Logout(){webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);webDriver.findElement(By.cssSelector("body > div.nav > a:nth-child(6)")).click();webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//获取alert()文字String text = webDriver.switchTo().alert().getText();String except_text = "是否确定注销?";webDriver.switchTo().alert().accept();webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//校验URL(登录)String cur_url = webDriver.getCurrentUrl();webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);//校验提交按钮WebElement webElement = webDriver.findElement(By.cssSelector("#submit"));webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);Assertions.assertEquals(except_text,text);Assertions.assertEquals("http://154.8.139.1:48080/login.html",cur_url);Assertions.assertNotNull(webElement);}

InitAndEnd类

package Blog;import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;import java.util.concurrent.TimeUnit;public class InitAndEnd {static WebDriver webDriver;@BeforeAllstatic void SetUp(){webDriver = new ChromeDriver();}@AfterAllstatic void TearDown(){webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);webDriver.quit();}
}

问题总结:

❓在测试程序执行报unexpected alert open: {Alert text : 恭喜:删除成功}这种异常,那么就是你没有将这个弹窗关闭掉

✨可以使用accept()方法接受或者dismiss()拒绝

http://www.hkea.cn/news/682282/

相关文章:

  • 网站后台上传图片失败百度下载免费安装最新版
  • 镇江做网站需要多少钱企业网站模板设计
  • 西安seo优化系统网页seo
  • 如何用网站模板做网站广州网络营销推广
  • 承德手机网站建设seo推广排名
  • wordpress块引用一个网站可以优化多少关键词
  • 360网站卖东西怎么做的无锡seo优化公司
  • 邢台人民网站百度视频推广怎么收费
  • 常州天启建设公司网站高端快速建站
  • ppt模板免费下载网站不用登录seo测试工具
  • 四川建设人才网官网查询阜新网站seo
  • 太原网站开发定制百度网盘官网下载
  • 业主装修日记那个网站做的好片多多可以免费看电视剧吗
  • 租车网站建设站长之家源码
  • 昌吉州回族自治州建设局网站地产渠道12种拓客方式
  • 北京市网站公司网络项目免费的资源网
  • 电子商务网站规划、电子商务网站建设站长工具 忘忧草
  • 凡科建网关键词优化公司哪家好
  • seo排名推广工具seo公司多少钱
  • 做视频网站赚钱怎么在百度上推广自己的公司信息
  • 网站建设凡科厦门网站建设平台
  • 互联网行业pest分析福州百度快速优化排名
  • 做网站的接私活犯法吗如何对网站进行推广
  • 身高差效果图网站优化师和运营区别
  • 谷歌wordpress建站搜索引擎算法
  • .net 购物网站开发源代码发布信息的免费平台
  • 自己做一网站大学生网络营销策划书
  • 关于网站建设的文章百度域名收录提交入口
  • 国人在线做网站推广图片大全
  • 郑州网站建设七彩科技四年级说新闻2023