提交 f22714a0 authored 作者: mry's avatar mry

feat(CRUD测试):完成了基本的增删改查功能的测试

上级 368a9aec
...@@ -57,7 +57,7 @@ public class ConferenceActive { ...@@ -57,7 +57,7 @@ public class ConferenceActive {
} }
//精准查询人数/会议室规模 //精准查询人数/会议室规模
private void extracted(String s, String ss) { private void preciseQuery(String s, String ss) {
String test; String test;
WebElement tbody = webDriver.findElement(By.xpath("/html/body/div/div/div[2]/div[2]/div/div/div[2]/div[1]/div[3]/table/tbody")); WebElement tbody = webDriver.findElement(By.xpath("/html/body/div/div/div[2]/div[2]/div/div/div[2]/div[1]/div[3]/table/tbody"));
List<WebElement> rows = tbody.findElements(By.className("el-table__row")); List<WebElement> rows = tbody.findElements(By.className("el-table__row"));
...@@ -72,12 +72,30 @@ public class ConferenceActive { ...@@ -72,12 +72,30 @@ public class ConferenceActive {
} }
} }
//修改test会议室
private void updateErrorMeetTest() {
meetManager();
WebElement tbody = webDriver.findElement(By.xpath("/html/body/div/div/div[2]/div[2]/div/div/div[2]/div[1]/div[3]/table/tbody"));
List<WebElement> rows = tbody.findElements(By.className("el-table__row"));
for (WebElement row : rows) {
String text = row.findElement(By.cssSelector(".el-table_2_column_9.el-table__cell")).getText();
if ("test".equals(text)) {
WebElement element = row.findElement(By.cssSelector(".el-table_2_column_14.el-table__cell"));
List<WebElement> spans = element.findElements(By.tagName("span"));
for (WebElement span : spans) {
if ("修改".equals(span.getText())) {
span.click();
}
}
}
}
}
//登录 //登录
public void login(String username, String password) { public void login(String username, String password) {
//todo 这个系统暂时没有登录的功能 //todo 这个系统暂时没有登录的功能
} }
@Test
//进入页面,并且到达会议室库管理页面 //进入页面,并且到达会议室库管理页面
public void meetManager() { public void meetManager() {
webDriver.get("http://123.60.53.83"); webDriver.get("http://123.60.53.83");
...@@ -100,17 +118,34 @@ public class ConferenceActive { ...@@ -100,17 +118,34 @@ public class ConferenceActive {
WebElement tbody = webDriver.findElement(By.xpath("/html/body/div/div/div[2]/div[2]/div/div/div[2]/div[1]/div[3]/table/tbody")); WebElement tbody = webDriver.findElement(By.xpath("/html/body/div/div/div[2]/div[2]/div/div/div[2]/div[1]/div[3]/table/tbody"));
List<WebElement> rows = tbody.findElements(By.className("el-table__row")); List<WebElement> rows = tbody.findElements(By.className("el-table__row"));
int size = rows.size(); int size = rows.size();
if (size == 6) { Assert.assertEquals(6, size);
test = "重置成功";
} else {
test = "重置失败";
}
Assert.assertEquals("重置成功", test);
} catch (Exception | Error e) { } catch (Exception | Error e) {
file(); file();
Assert.fail(e.getMessage()); Assert.fail(e.getMessage());
} }
}
@Test(description = "查询人数,输入负号")
public void findUnNumber() {
try {
meetManager();
//容纳人数查询
webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[2]/div/div/div/input")).click();
webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[2]/div/div/div/input")).clear();
webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[2]/div/div/div/input")).sendKeys("-");
String text = webDriver.findElement(By.className("el-message__content")).getText();
Assert.assertEquals("请输入数字", text);
//点击新增
webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/button/span")).click();
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[3]/div/div/input")).click();
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[3]/div/div/input")).clear();
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[3]/div/div/input")).sendKeys("-");
String text1 = webDriver.findElement(By.className("el-message__content")).getText();
Assert.assertEquals("请输入数字", text1);
} catch (Exception | Error e) {
file();
Assert.fail(e.getMessage());
}
} }
//按会议室名称模糊查询 //按会议室名称模糊查询
...@@ -152,7 +187,7 @@ public class ConferenceActive { ...@@ -152,7 +187,7 @@ public class ConferenceActive {
webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[2]/div/div/div/input")).clear(); webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[2]/div/div/div/input")).clear();
webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[2]/div/div/div/input")).sendKeys("130"); webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[2]/div/div/div/input")).sendKeys("130");
webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[4]/button[1]/span")).click(); webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[4]/button[1]/span")).click();
extracted(".el-table_2_column_12.el-table__cell", "130"); preciseQuery(".el-table_2_column_12.el-table__cell", "130");
} catch (Exception | Error e) { } catch (Exception | Error e) {
file(); file();
Assert.fail(e.getMessage()); Assert.fail(e.getMessage());
...@@ -164,21 +199,18 @@ public class ConferenceActive { ...@@ -164,21 +199,18 @@ public class ConferenceActive {
try { try {
meetManager(); meetManager();
WebElement find = webDriver.findElement(By.xpath("/html/body/div/div/div[2]/div[2]/div/div/div[1]/form/div/div[4]/button[1]/span")); WebElement find = webDriver.findElement(By.xpath("/html/body/div/div/div[2]/div[2]/div/div/div[1]/form/div/div[4]/button[1]/span"));
webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[3]/div/div/div/div/input")).click(); webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[3]/div/div/div/div/input")).click();
webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div[1]/ul/li[1]/span")).click(); webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div[1]/ul/li[1]/span")).click();
find.click(); find.click();
extracted(".el-table_2_column_11.el-table__cell", "小型会议室"); preciseQuery(".el-table_2_column_11.el-table__cell", "小型会议室");
webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[3]/div/div/div/div/input")).click(); webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[3]/div/div/div/div/input")).click();
webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div[1]/ul/li[2]/span")).click(); webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div[1]/ul/li[2]/span")).click();
find.click(); find.click();
extracted(".el-table_2_column_11.el-table__cell", "中型会议室"); preciseQuery(".el-table_2_column_11.el-table__cell", "中型会议室");
webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[3]/div/div/div/div/input")).click(); webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[3]/div/div/div/div/input")).click();
webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div[1]/ul/li[3]/span")).click(); webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div[1]/ul/li[3]/span")).click();
find.click(); find.click();
extracted(".el-table_2_column_11.el-table__cell", "大型会议室"); preciseQuery(".el-table_2_column_11.el-table__cell", "大型会议室");
} catch (Exception | Error e) { } catch (Exception | Error e) {
file(); file();
Assert.fail(e.getMessage()); Assert.fail(e.getMessage());
...@@ -219,11 +251,10 @@ public class ConferenceActive { ...@@ -219,11 +251,10 @@ public class ConferenceActive {
file(); file();
Assert.fail(e.getMessage()); Assert.fail(e.getMessage());
} }
} }
//新增会议室 //新增会议室
@Test(description = "会议室新增成功测试") @Test(description = "会议室新增测试")
public void insertMeet() { public void insertMeet() {
try { try {
meetManager(); meetManager();
...@@ -235,8 +266,6 @@ public class ConferenceActive { ...@@ -235,8 +266,6 @@ public class ConferenceActive {
webDriver.findElement(By.xpath("/html/body/div[4]/div[1]/div[1]/ul/li[1]/span")).click(); webDriver.findElement(By.xpath("/html/body/div[4]/div[1]/div[1]/ul/li[1]/span")).click();
//点击保存 //点击保存
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[3]/span/button[2]/span")).click(); webDriver.findElement(By.xpath("/html/body/div[2]/div/div[3]/span/button[2]/span")).click();
//防止截取不到提示信息
Thread.sleep(100);
String text = webDriver.findElement(By.className("el-message__content")).getText(); String text = webDriver.findElement(By.className("el-message__content")).getText();
Assert.assertEquals("新增成功!", text); Assert.assertEquals("新增成功!", text);
} catch (Exception | Error e) { } catch (Exception | Error e) {
...@@ -257,7 +286,6 @@ public class ConferenceActive { ...@@ -257,7 +286,6 @@ public class ConferenceActive {
Thread.sleep(100); Thread.sleep(100);
String text = webDriver.findElement(By.className("el-message__content")).getText(); String text = webDriver.findElement(By.className("el-message__content")).getText();
Assert.assertEquals("请填写具体信息", text); Assert.assertEquals("请填写具体信息", text);
//必填内容提示信息 //必填内容提示信息
String name = webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[1]/div/div[2]")).getText(); String name = webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[1]/div/div[2]")).getText();
String address = webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[2]/div/div[2]")).getText(); String address = webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[2]/div/div[2]")).getText();
...@@ -267,39 +295,60 @@ public class ConferenceActive { ...@@ -267,39 +295,60 @@ public class ConferenceActive {
Assert.assertEquals("请输入会议室地址", address); Assert.assertEquals("请输入会议室地址", address);
Assert.assertEquals("请输入容纳人数", number); Assert.assertEquals("请输入容纳人数", number);
Assert.assertEquals("请输入会议室规模", scale); Assert.assertEquals("请输入会议室规模", scale);
} catch (Exception | Error e) { } catch (Exception | Error e) {
file(); file();
Assert.fail(e.getMessage()); Assert.fail(e.getMessage());
} }
} }
//修改会议室 @Test(description = "新增错误会议室")
@Test(description = "会议室信息修改成功测试") public void insertErrorMeet() {
public void updateMeet() {
try { try {
meetManager(); meetManager();
WebElement tbody = webDriver.findElement(By.xpath("/html/body/div/div/div[2]/div[2]/div/div/div[2]/div[1]/div[3]/table/tbody")); //点击新增
List<WebElement> rows = tbody.findElements(By.className("el-table__row")); webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/button/span")).click();
for (WebElement row : rows) { popUp("test", "test1", "-qwe123");
String text = row.findElement(By.cssSelector(".el-table_2_column_9.el-table__cell")).getText(); //选择规模
if ("test".equals(text)) { webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[4]/div/div/div/span/span/i")).click();
WebElement element = row.findElement(By.cssSelector(".el-table_2_column_14.el-table__cell")); webDriver.findElement(By.xpath("/html/body/div[4]/div[1]/div[1]/ul/li[1]/span")).click();
List<WebElement> spans = element.findElements(By.tagName("span")); //点击保存
for (WebElement span : spans) { webDriver.findElement(By.xpath("/html/body/div[2]/div/div[3]/span/button[2]/span")).click();
if ("修改".equals(span.getText())) { String text = webDriver.findElement(By.className("el-message__content")).getText();
span.click(); Assert.assertEquals("新增失败!", text);
} catch (Exception | Error e) {
file();
Assert.fail(e.getMessage());
} }
} }
@Test(description = "修改成错误会议室")
public void updateErrorMeet() {
try {
updateErrorMeetTest();
popUp("testing", "testing1", "-qwe");
//点击保存
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[3]/span/button[2]/span")).click();
String text = webDriver.findElement(By.className("el-message__content")).getText();
Assert.assertEquals("修改失败!", text);
} catch (Exception | Error e) {
file();
Assert.fail(e.getMessage());
} }
} }
//修改会议室
@Test(description = "会议室信息修改成功测试")
public void updateMeet() {
try {
updateErrorMeetTest();
popUp("testing", "testing1", "200"); popUp("testing", "testing1", "200");
//修改规模 //修改规模
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[4]/div/div/div/span/span/i")).click(); webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[4]/div/div/div/span/span/i")).click();
webDriver.findElement(By.xpath("/html/body/div[4]/div[1]/div[1]/ul/li[3]/span")).click(); webDriver.findElement(By.xpath("/html/body/div[4]/div[1]/div[1]/ul/li[3]/span")).click();
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[3]/span/button[2]/span")).click(); webDriver.findElement(By.xpath("/html/body/div[2]/div/div[3]/span/button[2]/span")).click();
//防止截取不到提示信息 //点击保存
Thread.sleep(100); webDriver.findElement(By.xpath("/html/body/div[2]/div/div[3]/span/button[2]/span")).click();
String text = webDriver.findElement(By.className("el-message__content")).getText(); String text = webDriver.findElement(By.className("el-message__content")).getText();
Assert.assertEquals("修改成功!", text); Assert.assertEquals("修改成功!", text);
} catch (Exception | Error e) { } catch (Exception | Error e) {
...@@ -328,8 +377,6 @@ public class ConferenceActive { ...@@ -328,8 +377,6 @@ public class ConferenceActive {
} }
} }
} }
//防止截取不到提示信息
Thread.sleep(100);
String text = webDriver.findElement(By.className("el-message__content")).getText(); String text = webDriver.findElement(By.className("el-message__content")).getText();
Assert.assertEquals("删除成功!", text); Assert.assertEquals("删除成功!", text);
} catch (Exception | Error e) { } catch (Exception | Error e) {
......
...@@ -12,11 +12,15 @@ ...@@ -12,11 +12,15 @@
<class name="com.tykj.selenium.conferenceRoomTest.ConferenceActive"/> <class name="com.tykj.selenium.conferenceRoomTest.ConferenceActive"/>
<methods> <methods>
<include name="resetTest"/> <include name="resetTest"/>
<include name="findUnNumber"/>
<include name="findMeetName"/> <include name="findMeetName"/>
<include name="findNumberMeet"/> <include name="findNumberMeet"/>
<include name="findScaleMeet"/> <include name="findScaleMeet"/>
<include name="findMeet"/>
<include name="insertMeet"/> <include name="insertMeet"/>
<include name="insertNullMeetFail"/> <include name="insertNullMeetFail"/>
<include name="insertErrorMeet"/>
<include name="updateErrorMeet"/>
<include name="updateMeet"/> <include name="updateMeet"/>
<include name="deleteMeet"/> <include name="deleteMeet"/>
</methods> </methods>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论