提交 368a9aec authored 作者: mry's avatar mry

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

上级 9fb80da0
...@@ -57,13 +57,13 @@ public class ConferenceActive { ...@@ -57,13 +57,13 @@ public class ConferenceActive {
} }
//精准查询人数/会议室规模 //精准查询人数/会议室规模
private void extracted(String s, String scale) { private void extracted(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"));
for (WebElement row : rows) { for (WebElement row : rows) {
String text = row.findElement(By.cssSelector(s)).getText(); String text = row.findElement(By.cssSelector(s)).getText();
if (scale.equals(text)) { if (ss.equals(text)) {
test = "查询成功"; test = "查询成功";
} else { } else {
test = "查询失败"; test = "查询失败";
...@@ -72,6 +72,7 @@ public class ConferenceActive { ...@@ -72,6 +72,7 @@ public class ConferenceActive {
} }
} }
//登录
public void login(String username, String password) { public void login(String username, String password) {
//todo 这个系统暂时没有登录的功能 //todo 这个系统暂时没有登录的功能
} }
...@@ -86,6 +87,32 @@ public class ConferenceActive { ...@@ -86,6 +87,32 @@ public class ConferenceActive {
webDriver.findElement(By.xpath("/html/body/div/div/div[2]/div[1]/div/ul/li/ul/li[1]/div/span[2]")).click(); webDriver.findElement(By.xpath("/html/body/div/div/div[2]/div[1]/div/ul/li/ul/li[1]/div/span[2]")).click();
} }
@Test(description = "验证重置按钮")
public void resetTest() {
try {
String test;
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("100");
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[2]/span")).click();
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"));
int size = rows.size();
if (size == 6) {
test = "重置成功";
} else {
test = "重置失败";
}
Assert.assertEquals("重置成功", test);
} catch (Exception | Error e) {
file();
Assert.fail(e.getMessage());
}
}
//按会议室名称模糊查询 //按会议室名称模糊查询
@Test(description = "会议室模糊查询") @Test(description = "会议室模糊查询")
public void findMeetName() { public void findMeetName() {
...@@ -101,14 +128,14 @@ public class ConferenceActive { ...@@ -101,14 +128,14 @@ public class ConferenceActive {
List<WebElement> rows = tbody.findElements(By.className("el-table__row")); List<WebElement> rows = tbody.findElements(By.className("el-table__row"));
for (WebElement row : rows) { for (WebElement row : rows) {
String text = row.findElement(By.cssSelector(".el-table_2_column_9.el-table__cell")).getText(); String text = row.findElement(By.cssSelector(".el-table_2_column_9.el-table__cell")).getText();
if (text.indexOf("G")!=(-1)){ if (text.indexOf("G") != (-1)) {
test = "查询成功"; test = "查询成功";
}else { } else {
test = "查询失败"; test = "查询失败";
} }
Assert.assertEquals("查询成功",test); Assert.assertEquals("查询成功", test);
} }
}catch (Exception | Error e){ } catch (Exception | Error e) {
file(); file();
Assert.fail(e.getMessage()); Assert.fail(e.getMessage());
} }
...@@ -116,7 +143,7 @@ public class ConferenceActive { ...@@ -116,7 +143,7 @@ public class ConferenceActive {
//按容纳人数精准查询 //按容纳人数精准查询
@Test(description = "容纳人数精准查询") @Test(description = "容纳人数精准查询")
public void findNumberMeet(){ public void findNumberMeet() {
try { try {
String test; String test;
meetManager(); meetManager();
...@@ -126,7 +153,7 @@ public class ConferenceActive { ...@@ -126,7 +153,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")).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"); extracted(".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());
} }
...@@ -134,6 +161,7 @@ public class ConferenceActive { ...@@ -134,6 +161,7 @@ public class ConferenceActive {
@Test(description = "按照会议室规模查询") @Test(description = "按照会议室规模查询")
public void findScaleMeet() { public void findScaleMeet() {
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"));
...@@ -151,6 +179,47 @@ public class ConferenceActive { ...@@ -151,6 +179,47 @@ public class ConferenceActive {
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", "大型会议室"); extracted(".el-table_2_column_11.el-table__cell", "大型会议室");
} catch (Exception | Error e) {
file();
Assert.fail(e.getMessage());
}
}
@Test(description = "所有条件查询会议室")
public void findMeet() {
try {
String test;
meetManager();
webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/form/div/div[1]/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[1]/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[1]/div/div/div/input")).sendKeys("G");
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("130");
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/div/div[2]/div[2]/div/div/div[1]/form/div/div[4]/button[1]/span")).click();
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 name = row.findElement(By.cssSelector(".el-table_2_column_9.el-table__cell")).getText();
System.out.println(name);
String number = row.findElement(By.cssSelector(".el-table_2_column_12.el-table__cell")).getText();
System.out.println(number);
String scale = row.findElement(By.cssSelector(".el-table_2_column_11.el-table__cell")).getText();
System.out.println(scale);
if (name.indexOf("G") != (-1) && "130".equals(number) && "中型会议室".equals(scale)) {
test = "查询成功";
} else {
test = "查询失败";
}
Assert.assertEquals("查询成功", test);
}
} catch (Exception | Error e) {
file();
Assert.fail(e.getMessage());
}
} }
//新增会议室 //新增会议室
...@@ -205,15 +274,6 @@ public class ConferenceActive { ...@@ -205,15 +274,6 @@ public class ConferenceActive {
} }
} }
// @Test
// public void insertNoNumber(){
// meetManager();
// //点击新增
// webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/button/span")).click();
// extracted("去q1","去q2","-");
//
// }
//修改会议室 //修改会议室
@Test(description = "会议室信息修改成功测试") @Test(description = "会议室信息修改成功测试")
public void updateMeet() { public void updateMeet() {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<classes> <classes>
<class name="com.tykj.selenium.conferenceRoomTest.ConferenceActive"/> <class name="com.tykj.selenium.conferenceRoomTest.ConferenceActive"/>
<methods> <methods>
<include name="resetTest"/>
<include name="findMeetName"/> <include name="findMeetName"/>
<include name="findNumberMeet"/> <include name="findNumberMeet"/>
<include name="findScaleMeet"/> <include name="findScaleMeet"/>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论