selenium RC优化代码3
1、增加测试用例( 重新写一个公共方法即可)
1)增加一个 @Test
2)编写新测试用例的公共方法
注:@before、@after会在每个测试用例执行完了之后,再执行一遍,这样会造成不能在第一个测试用例
基础上继续进行第2个测试用例,可能会没有保留登陆状态等
解决方案:
解决方法:如果是没有保留登录状态,那么就增加登录的代码;
2、注释测试用例
将 @test用//注释掉即可,这样junit会不再执行它
删除断言:
1、
String msgText = selenium.getText("id=msg"); if (msgText.contains("删除数据成功"))//判断提示信息中包含“删除数据成功”字样 System.out.println("删除公告成功"); else System.out.println("删除公告失败");
2、可通过数据库方式来断言
1)获取删除前,数据的数量
String sql ="select count(*) from notice"; int totalBefore = this.getCount(sql);
2)执行删除操作,对比删除后的数据数量
int totalAfter = this.getCount(sql); if (totalAfter +1 == totalBefore) System.out.println("删除公告成功"); else System.out.println("删除公告失败");