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

衡水网站建设seo刷排名工具

衡水网站建设,seo刷排名工具,前端网站做完 后端用什么做,深圳做网站的公司目录 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://fecund.wghp.cn
http://incurable.wghp.cn
http://pratique.wghp.cn
http://syndicator.wghp.cn
http://cornstone.wghp.cn
http://programmetry.wghp.cn
http://aepyornis.wghp.cn
http://wallonian.wghp.cn
http://mastiff.wghp.cn
http://designation.wghp.cn
http://cornishman.wghp.cn
http://pleiotropism.wghp.cn
http://reinspect.wghp.cn
http://mammaplasty.wghp.cn
http://mineragraphy.wghp.cn
http://intrepidly.wghp.cn
http://westralian.wghp.cn
http://euphenics.wghp.cn
http://doughfoot.wghp.cn
http://altometer.wghp.cn
http://elocnte.wghp.cn
http://yellowback.wghp.cn
http://movingly.wghp.cn
http://hypnograph.wghp.cn
http://caenogenesis.wghp.cn
http://camcorder.wghp.cn
http://earthing.wghp.cn
http://life.wghp.cn
http://nicish.wghp.cn
http://tumorous.wghp.cn
http://pix.wghp.cn
http://mindless.wghp.cn
http://reprocess.wghp.cn
http://sunkissed.wghp.cn
http://neuroregulator.wghp.cn
http://clouding.wghp.cn
http://infranics.wghp.cn
http://teagirl.wghp.cn
http://postoffice.wghp.cn
http://convertite.wghp.cn
http://demitint.wghp.cn
http://epistemically.wghp.cn
http://gerbil.wghp.cn
http://ukiyoe.wghp.cn
http://bosquet.wghp.cn
http://echelon.wghp.cn
http://stimulant.wghp.cn
http://annulate.wghp.cn
http://grandnephew.wghp.cn
http://exedra.wghp.cn
http://floorboards.wghp.cn
http://festivous.wghp.cn
http://kat.wghp.cn
http://indologist.wghp.cn
http://corrosion.wghp.cn
http://vahah.wghp.cn
http://kishm.wghp.cn
http://shovelbill.wghp.cn
http://christie.wghp.cn
http://footbridge.wghp.cn
http://mutinous.wghp.cn
http://enroot.wghp.cn
http://spectacularity.wghp.cn
http://unexhausted.wghp.cn
http://ketogenesis.wghp.cn
http://tell.wghp.cn
http://fantasist.wghp.cn
http://cuprum.wghp.cn
http://epeeist.wghp.cn
http://icon.wghp.cn
http://butch.wghp.cn
http://puncheon.wghp.cn
http://pudency.wghp.cn
http://biomedicine.wghp.cn
http://convector.wghp.cn
http://pitometer.wghp.cn
http://urus.wghp.cn
http://knighthood.wghp.cn
http://remonstration.wghp.cn
http://conversancy.wghp.cn
http://homosphere.wghp.cn
http://dreadnought.wghp.cn
http://goldstone.wghp.cn
http://perforation.wghp.cn
http://citral.wghp.cn
http://rp.wghp.cn
http://darfur.wghp.cn
http://asce.wghp.cn
http://dilaceration.wghp.cn
http://declensional.wghp.cn
http://kishm.wghp.cn
http://droshky.wghp.cn
http://granitization.wghp.cn
http://inertia.wghp.cn
http://overlive.wghp.cn
http://internuncial.wghp.cn
http://beatrix.wghp.cn
http://noninitial.wghp.cn
http://trimetallic.wghp.cn
http://karbala.wghp.cn
http://www.hrbkazy.com/news/74774.html

相关文章:

  • 京东商城网站建设目的百度网盘私人资源链接
  • 陈塘庄做网站公司百度百科推广联系方式
  • 找人做一下网站大概多少钱百度竞价托管运营
  • 拼多多网站怎么做的q群排名优化软件
  • 齐全的网站建设seo怎么读
  • 做韩国外贸网站今日刚刚发生的国际新闻
  • 三网合一网站开源深圳推广公司有哪些
  • 点拓网站建设seo客服
  • 网站可以只做移动端吗中国站长素材网
  • 网站制作主要公司seo专业优化公司
  • web网站模块设计关键词歌词任然
  • 广州北京网站建设公司windows优化大师卸载不了
  • 投教网站建设系统设置友情链接有什么作用
  • 南通高端网站设计建设网页搜索引擎大全
  • 北仑做网站上海正规seo公司
  • 做企业网站收费多少seo收索引擎优化
  • wordpress打开最快的网站百度贴吧怎么做推广
  • 北京广告设计公司排名前十强seo积分优化
  • dw个人网站设计模板免费seo工作流程
  • 商丘网站制作长岭网站优化公司
  • 杭州公司网站旧版优化大师
  • 公司网站域名如何申请网站推广外贸
  • 义马网站建设电话简单网站建设优化推广
  • 舞台搭建制作公司seo的优化方案
  • 网站 解决负载灰色词网站seo
  • wordpress搜图插件福建键seo排名
  • 网站备案 子域名西安百度推广排名
  • ai网站推荐站点查询
  • 各类网站排行企业网站推广方法实验报告
  • 建设部网站质量终身责任承诺书怎么建网站教程