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

商丘购物网站开发设计做像淘宝网的网站

商丘购物网站开发设计,做像淘宝网的网站,宁夏网站设计公司,杭州公司网站设计自动化博客项目 用户注册登录验证效验个人博客列表页博客数量不为 0 博客系统主页写博客 我的博客列表页效验 刚发布的博客的标题和时间查看 文章详情页删除文章效验第一篇博客 不是 "自动化测试" 注销退出到登录页面,用户名密码为空 用户注册 Order(1)Parameterized…

在这里插入图片描述

自动化博客项目

  • 用户注册
  • 登录验证
    • 效验个人博客列表页博客数量不为 0
  • 博客系统主页
    • 写博客
  • 我的博客列表页
    • 效验 刚发布的博客的标题和时间
    • 查看 文章详情页
    • 删除文章
      • 效验第一篇博客 不是 "自动化测试"
    • 注销
      • 退出到登录页面,用户名密码为空

用户注册

在这里插入图片描述

 @Order(1)@ParameterizedTest@CsvFileSource(resources = "regmes.csv")void Reg(String username , String password , String password2) throws InterruptedException {webDriver.get("http://211.159.172.237:8080/reg.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("#password2")).sendKeys(password2);webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);sleep(2000);//点击注册webDriver.findElement(By.cssSelector("#submit")).click();webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);sleep(2000);webDriver.switchTo().alert().accept();

在这里插入图片描述

登录验证

在这里插入图片描述

 @Order(2)@ParameterizedTest@CsvFileSource(resources = "LoginSuccess.csv")void LoginSuccess(String username , String password , String blog_list_url) throws InterruptedException {//打开登录页webDriver.get("http://211.159.172.237:8080/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);sleep(3000);webDriver.findElement(By.cssSelector("#submit")).click();webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);sleep(1000);//验证urlString cur_url = webDriver.getCurrentUrl();Assertions.assertEquals(blog_list_url, cur_url);}

在这里插入图片描述

效验个人博客列表页博客数量不为 0

在这里插入图片描述

@Order(3)@Test//效验 个人博客列表页博客数量不为 0void MyBlogList() throws InterruptedException {webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);sleep(3000);int title_num = webDriver.findElements(By.cssSelector(".title")).size();Assertions.assertNotEquals(0,title_num);}

博客系统主页

在这里插入图片描述

写博客

在这里插入图片描述

 @Order(4)@Testvoid AddBlog() throws InterruptedException {//到系统主页看看webDriver.findElement(By.cssSelector("body > div.nav > a:nth-child(4)")).click();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);//通过js输入((JavascriptExecutor)webDriver).executeScript("document.getElementById(\"title\").value=\"自动化测试\"");sleep(1500);//点击发布webDriver.findElement(By.cssSelector("body > div.blog-edit-container > div.title > button")).click();sleep(1500);webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//弹窗点击取消webDriver.switchTo().alert().dismiss();String cur_url = webDriver.getCurrentUrl();Assertions.assertEquals("http://211.159.172.237:8080/myblog_list.html",cur_url);sleep(1500);//        webDriver.switchTo().alert().accept();}

我的博客列表页

在这里插入图片描述

效验 刚发布的博客的标题和时间

    @Order(5)@Test//效验已发布博客的标题和时间void BlogInfoChecked() throws InterruptedException {webDriver.get("http://211.159.172.237:8080/myblog_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.xpath("//*[@id=\"artListDiv\"]/div[1]/div[2]")).getText();Assertions.assertEquals("自动化测试",first_blog_title);sleep(3000);if(first_blog_time.contains("2023-10-28")) {System.out.println("时间正确");}else {System.out.println("当前时间是 :" + first_blog_time);System.out.println("时间错误");}}

查看 文章详情页

在这里插入图片描述

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class BlogCases extends InitAndEnd{public static Stream<Arguments> Generator() {return Stream.of(Arguments.arguments("http://211.159.172.237:8080/blog_content.html","博客正文","自动化测试"));}@Order(6)@ParameterizedTest@MethodSource("Generator")//博客详情页void BlogContent(String expected_url , String expected_title , String expected_blog_title) throws InterruptedException {webDriver.findElement(By.xpath("//*[@id=\"artListDiv\"]/div[1]/a[1]")).click();sleep(3000);//获取当前页面的url , http://211.159.172.237:8080/blog_content.html?aid=15String cur_url = webDriver.getCurrentUrl();webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//获取当前页面的标题 , 博客正文String cur_title = webDriver.getTitle();webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//获取当前博客的标题 , 自动化测试String blog_title = webDriver.findElement(By.cssSelector("#title")).getText();webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);//        Assertions.assertEquals(expected_url , cur_url);Assertions.assertEquals(expected_title , cur_title);Assertions.assertEquals(expected_blog_title , blog_title);if(cur_url.contains(expected_url)) {System.out.println("博客详情正确");} else {System.out.println(cur_url);System.out.println("博客详情失败");}sleep(1500);}

删除文章

在这里插入图片描述

效验第一篇博客 不是 “自动化测试”

 @Order(7)@Test//删除刚刚发布的博客void DeleteBlog() throws InterruptedException {webDriver.get("http://211.159.172.237:8080/myblog_list.html");webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);webDriver.findElement(By.cssSelector("#artListDiv > div:nth-child(1) > a:nth-child(6)")).click();webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);sleep(3000);webDriver.switchTo().alert().accept();//效验第一篇博客不是 "自动化测试"String first_blog_title = webDriver.findElement(By.cssSelector("#artListDiv > div:nth-child(1) > div.title")).getText();webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);Assertions.assertNotEquals("自动化测试",first_blog_title);sleep(3000);}

注销

在这里插入图片描述

@Order(8)@Test//注销void Logout() throws InterruptedException {webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
//        webDriver.findElement(By.cssSelector("body > div.nav > a:nth-child(6)"));webDriver.findElement(By.xpath("/html/body/div[1]/a[3]")).click();webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);webDriver.switchTo().alert().accept();sleep(3000);String cur_url = webDriver.getCurrentUrl();Assertions.assertEquals("http://211.159.172.237:8080/login.html",cur_url);}

退出到登录页面,用户名密码为空

在这里插入图片描述

http://www.yayakq.cn/news/606539/

相关文章:

  • 辽源网站制作爱站网关键词查询系统
  • windows 2008 iis添加网站glitch做网站
  • 推广产品的软文怎么写seo网站推广免费
  • 义乌制作网站开发深圳惠州网站建设
  • dreamwearver做网站地图北京安卓app开发公司
  • 设计师培训班费用石家庄桥西招聘 网站优化
  • 卡盟网站建设wordpress短代码教程
  • dedecms 网站重复文章项目计划书包括哪些内容
  • 加强网站功能建设如何做伪原创文章网站
  • 国外做机器人的网站手机如何创造网站
  • 中国住房和城乡建设部网站小说小程序源码
  • 衡阳微信网站wordpress手机菜单导航
  • 家用电器行业外贸建站怎么获取网站ftp地址
  • 哈尔滨优化建站哪家专业wordpress中文主程序优化
  • 网站模板目录扫描企业网络营销策划书模板
  • 网站显示速度的代码是什么意思建筑网官网登录
  • 宁德市路桥建设有限公司网站人事处网站建设绩效目标概述
  • 快速做网站服务好北京建网站价格
  • 什么是网站什么是网页加密的网站使用jmeter做压测
  • access如何与网站连接数据库襄阳网站建设feeyr
  • vs2010网站开发与发布网上购物平台投诉电话
  • 做门户网站经验凡网站创建
  • 网络整合营销方案策划seo优化神器
  • wap网站搜索苏州专业网站设计
  • 北京建站公司哪家好医疗网站建设管理
  • 电商网站策划书百度app智能小程序
  • 手机网站开发步骤软件查询网址域名ip地址
  • 网站客户端制作教程麻花星空影视传媒制作公司网站
  • 上海平面设计公司排行榜北京seo案例
  • iis的网站登录没反应邯郸教育行业网站建设