脚本维护

This commit is contained in:
suntao 2017-02-28 14:41:12 +08:00
parent fcc4344752
commit b568764ea7
3 changed files with 50 additions and 64 deletions

View File

@ -132,6 +132,12 @@ public class course {
//11.验证点击归档是否弹出确认是否归档的提示弹框
dr.findElement(By.linkText("归档")).click();
try {
Thread.sleep(3000);
} catch (InterruptedException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
WebElement elHintFrame=dr.findElement(By.xpath("//*[@id='muban_popup_box']/div[2]/div/p"));
if(elHintFrame.isDisplayed())
System.out.println("11.测试通过,点击归档成功弹出是否确认归档的提示弹框");
@ -150,7 +156,7 @@ public class course {
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
dr.findElement(By.xpath("//*[@id='muban_popup_box']/div[2]/div/a")).click();
System.out.println("12.测试通过,测试班级已成功归档");

View File

@ -26,11 +26,11 @@ public class feedback {
dr.get("https://ucloudtest.trustie.net/courses/672/feedback"); //进入测试班级
//1.验证班级左侧导航留言返回留言页面
String urlFeedback=dr.findElement(By.xpath("//*[@id='navContentCourse']/li[1]/a[1]")).getAttribute("href");
String urlFeedback=dr.findElement(By.xpath("//*[@id='sy_06']/a[1]")).getAttribute("href");
System.out.println("1.班级左侧导航处留言返回:"+urlFeedback);
//2.验证班级留言页面顶部有用户留言字样
String bannerFeedback=dr.findElement(By.xpath("/html/body/div[4]/div[2]/div[2]/div/div[1]/h2")).getText();
String bannerFeedback=dr.findElement(By.xpath("//*[@id='mesLabel']")).getText();
System.out.println("2.班级留言页面顶部显示“"+bannerFeedback+"”字样");
//3.验证班级左侧导航处留言数统计
@ -39,15 +39,15 @@ public class feedback {
//4.验证留言内容为空时是否给出内容不能为空的提示信息
dr.findElement(By.linkText("留言")).click();
String tipJourNull=dr.findElement(By.xpath("//*[@id='course_feedback_new']/p[1]")).getText();
String tipJourNull=dr.findElement(By.xpath("//*[@id='jour_content_span']")).getText();
System.out.println("4.留言内容为空时,提示:"+tipJourNull);
//5.验证取消班级留言
WebElement frameFeedbackKeditor=dr.findElement(By.xpath("//*[@id='course_feedback_new']/div[3]/div[1]/iframe"));
WebElement frameFeedbackKeditor=dr.findElement(By.xpath("//*[@id='course_feedback_new']/li/div[1]/div[2]/iframe"));
dr.switchTo().frame(frameFeedbackKeditor);
dr.findElement(By.xpath("/html/body")).sendKeys("班级留言内容");
dr.switchTo().defaultContent(); //切回主文档
dr.findElement(By.id("new_message_cancel_btn_")).click();
dr.findElement(By.xpath("//*[@id='course_feedback_new']/a[2]")).click();
dr.switchTo().frame(frameFeedbackKeditor);
String jour=dr.findElement(By.xpath("/html/body")).getText();
System.out.println("5.留言内容为“"+jour+"”(预期输出为空),若留言内容为空,则测试通过,取消留言后,留言内容被自动清空");
@ -55,8 +55,8 @@ public class feedback {
//6.验证正常留言
dr.findElement(By.xpath("/html/body")).sendKeys("班级留言内容");
dr.switchTo().defaultContent();
dr.findElement(By.id("new_message_submit_btn_")).click();
dr.findElement(By.id("new_message_submit_btn_")).click();
dr.findElement(By.xpath("//*[@id='submit_feedback_user']")).click();
dr.findElement(By.xpath("//*[@id='submit_feedback_user']")).click();
System.out.println("6.测试通过,已成功留言");
//7.验证成功留言后留言数统计是否自动加1
@ -66,25 +66,27 @@ public class feedback {
System.out.println("7.当前留言数为:"+textCountJour+"(与用例3相比较留言数统计是否自动加1)");
//8.验证留言头像是否链接至对应用户的个人主页
String urlHead=dr.findElement(By.xpath("//*[contains(@id,'word_li')]/div[1]/a")).getAttribute("href");
String urlHead=dr.findElement(By.xpath("//*[contains(@id,'user_activity')]/div[1]//div[1]/a")).getAttribute("href");
System.out.println("8.当前留言人头像跳转至:"+urlHead);
//9.验证留言用户名是否链接至对应用户的个人主页
String urlUsername=dr.findElement(By.xpath("//*[contains(@id,'word_li')]/div[2]/div[1]/span[1]/a")).getAttribute("href");
String urlUsername=dr.findElement(By.xpath("//*[contains(@id,'user_activity')]/div[1]/div[2]/div[1]/a[1]")).getAttribute("href");
System.out.println("9.当前留言用户名跳转至:"+urlUsername);
//当前版本留言回复为空时不再给出提示而是收起发送按钮
//10.验证留言回复为空时是否给出回复内容不能为空的提示
dr.findElement(By.xpath("//a[contains(text(),'回复')]")).click();
try {
Thread.sleep(5000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
dr.findElement(By.xpath("//*[contains(@id,'project_respond_form')]/form/input[5]")).click();
String tipNull=dr.findElement(By.xpath("//*[contains(@id,'project_respond_form')]/form/p")).getText();
System.out.println("10.留言回复为空时,提示:"+tipNull);
WebElement iframeresponse=dr.findElement(By.xpath("//*[contains(@id,'activity_post_reply')]/div[2]/div[2]/div[1]/form/div[3]/div[1]/iframe"));
dr.switchTo().frame(iframeresponse);
dr.findElement(By.xpath("/html/body")).click();
dr.switchTo().defaultContent();
WebElement subBtn=dr.findElement(By.xpath("//a[contains(text(),'发送')]"));
subBtn.click();
if(subBtn.isDisplayed())
System.out.println("10.测试失败");
else
System.out.println("10.测试通过,留言回复为空则收起“发送”按钮");
//11.验证正常留言一级回复
//dr.findElement(By.xpath("//*[contains(@id,'word_li')]/div[2]/div[2]/a[1]")).click();
try {
@ -93,57 +95,28 @@ public class feedback {
// TODO Auto-generated catch block
e.printStackTrace();
}
WebElement frameReplyKeditor=dr.findElement(By.xpath("//*[contains(@id,'project_respond_form')]/form/div[2]/div[1]/iframe"));
dr.switchTo().frame(frameReplyKeditor);
//WebElement frameReplyKeditor=dr.findElement(By.xpath("//*[contains(@id,'project_respond_form')]/form/div[2]/div[1]/iframe"));
dr.switchTo().frame(iframeresponse);
dr.findElement(By.xpath("/html/body")).sendKeys("班级留言一级回复");
dr.switchTo().defaultContent();
dr.findElement(By.xpath("//*[contains(@id,'project_respond_form')]/form/input[5]")).click();
dr.findElement(By.xpath("//a[contains(text(),'发送')]")).click();
System.out.println("11.测试通过,已成功一级回复");
//12.验证正常留言多级回复
WebElement frameMulReplyKeditor=dr.findElement(By.xpath("//*[contains(@id,'project_respond_form')]/form/div[2]/div[1]/iframe"));
dr.switchTo().frame(frameMulReplyKeditor);
dr.findElement(By.xpath("/html/body")).sendKeys("班级留言二级回复");
dr.switchTo().defaultContent();
try {
Thread.sleep(5000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
WebElement iconMulResponse=dr.findElement(By.xpath("//*[contains(@id,'reply_respond_form')]/a[1]"));
//用JavaScript对隐藏的元素进行操作
JavascriptExecutor jsc = (JavascriptExecutor)dr;
jsc.executeScript("arguments[0].click();", iconMulResponse);
System.out.println("12.测试通过,已成功二级回复");
//13.验证留言赞取消赞
String iconCanceFavour=dr.findElement(By.xpath("//*[contains(@id,'word_li')]/div[2]/div[2]/span/a/span[1]")).getText();
System.out.println("13.1 未赞的状态为:"+iconCanceFavour);
dr.findElement(By.xpath("//*[contains(@id,'word_li')]/div[2]/div[2]/span/a/span[1]")).click();
//12.验证留言赞取消赞
String iconCanceFavour=dr.findElement(By.xpath("//*[contains(@id,'praise_count')]/a/span[1]")).getText();
System.out.println("12.1 未赞的状态为:"+iconCanceFavour);
dr.findElement(By.xpath("//*[contains(@id,'praise_count')]/a/span[1]")).click();
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String iconFavour=dr.findElement(By.xpath("//*[contains(@id,'word_li')]/div[2]/div[2]/span/a/span[1]")).getText();
System.out.println("13.2 已赞的状态显示为:"+iconFavour);
String iconFavour=dr.findElement(By.xpath("//*[contains(@id,'praise_count')]/a/span[1]")).getText();
System.out.println("12.2 已赞的状态显示为:"+iconFavour);
//14.验证留言回复的点赞取消赞
//用getAttribute("textContent")方法获取隐藏元素的text值
WebElement elResponceFavour=dr.findElement(By.xpath("//*[contains(@id,'reply_respond_form')]/span/a/span[1]"));
String textResponce=elResponceFavour.getAttribute("textContent");
System.out.println("14.1 留言回复未点赞状态显示为:"+textResponce);
//用JavaScript对隐藏的元素进行操作
JavascriptExecutor js = (JavascriptExecutor)dr;
js.executeScript("arguments[0].click();", elResponceFavour);
WebElement elCurrentResponce=dr.findElement(By.xpath("//*[contains(@id,'reply_respond_form')]/span/a"));
String textCurrentResponce=elCurrentResponce.getAttribute("title");
System.out.println("14.2 留言回复点赞后状态显示为:"+textCurrentResponce);
dr.quit(); //关闭浏览器窗口
}

View File

@ -1 +1,8 @@
测试代码说明
测试代码说明:
流程:
Selenium grid+java(或Python或Ruby)编写测试脚本并在代码中插入TestNG annotation
将测试信息添加到testng.xml文件或build.xml文件
运行TestNG
Jenkins持续集成评审通过
资源库上传文件弹框改版了,资源库脚本尚未更新