提交 69ae0465 authored 作者: mry's avatar mry

新的自动测试

上级 88b1357b
...@@ -7,10 +7,9 @@ import org.apache.commons.io.FileUtils; ...@@ -7,10 +7,9 @@ import org.apache.commons.io.FileUtils;
import org.openqa.selenium.*; import org.openqa.selenium.*;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.testng.Assert;
import org.testng.Reporter; import org.testng.Reporter;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.io.File; import java.io.File;
...@@ -41,335 +40,168 @@ public class ConferenceActive { ...@@ -41,335 +40,168 @@ public class ConferenceActive {
Reporter.log("<img src=/opt/meeting_deploy/images/" + fileName + " style=width:30px;height:30px />", true); Reporter.log("<img src=/opt/meeting_deploy/images/" + fileName + " style=width:30px;height:30px />", true);
} }
//新增或修改需要输入的数据 //进入会议室管理库
private void popUp(String name, String address, String s) { public void meetManage() {
//输入名称 try {
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[1]/div/div[1]/input")).click(); Thread.sleep(1000);
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[1]/div/div[1]/input")).clear(); } catch (InterruptedException e) {
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[1]/div/div[1]/input")).sendKeys(name); e.printStackTrace();
//输入地址
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[2]/div/div[1]/input")).click();
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[2]/div/div[1]/input")).clear();
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[2]/div/div[1]/input")).sendKeys(address);
//输入人数
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(s);
}
//精准查询人数/会议室规模
private void preciseQuery(String s, String ss) {
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"));
List<WebElement> rows = tbody.findElements(By.className("el-table__row"));
for (WebElement row : rows) {
String text = row.findElement(By.cssSelector(s)).getText();
if (ss.equals(text)) {
test = "查询成功";
} else {
test = "查询失败";
}
Assert.assertEquals("查询成功", test);
} }
} //点击系统管理按钮
webDriver.findElement(By.className("app_header")).findElement(By.className("app_header_right")).findElement(By.tagName("span")).click();
//修改test会议室 //进入库管理
private void updateErrorMeetTest() { WebElement sys = webDriver.findElement(By.className("sys_MenuList"));
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 ul = sys.findElement(By.tagName("ul"));
List<WebElement> rows = tbody.findElements(By.className("el-table__row")); WebElement li = ul.findElement(By.tagName("li"));
for (WebElement row : rows) { //点击库管理
String text = row.findElement(By.cssSelector(".el-table_2_column_9.el-table__cell")).getText(); li.findElement(By.tagName("span")).click();
if ("test".equals(text)) { //进入会议室库管理
WebElement element = row.findElement(By.cssSelector(".el-table_2_column_14.el-table__cell")); WebElement inline = webDriver.findElement(By.cssSelector(".el-menu.el-menu--inline"));
List<WebElement> spans = element.findElements(By.tagName("span")); List<WebElement> li1s = inline.findElements(By.tagName("li"));
for (WebElement span : spans) { for (WebElement li1 : li1s) {
if ("修改".equals(span.getText())) { WebElement name = li1.findElement(By.className("name"));
span.click(); String text = name.getText();
} if ("会议室库管理".equals(text)) {
} name.click();
} }
} }
} }
//登录 //登录
public void login(String username, String password) { @BeforeClass
//todo 这个系统暂时没有登录的功能 public void url() {
} webDriver.get("http://123.60.53.83/#/beforeMeeting");
@BeforeMethod
//进入页面,并且到达会议室库管理页面
public void meetManager() {
webDriver.get("http://123.60.53.83/");
webDriver.manage().window().maximize(); webDriver.manage().window().maximize();
webDriver.findElement(By.xpath("/html/body/div/div/div[1]/div[2]/div[2]/span")).click();
webDriver.findElement(By.xpath("/html/body/div/div/div[2]/div[1]/div/ul/li/div/span")).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() { @Test(description = "登录成功")
try { public void login() {
String test; //输入用户名
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/div/div/div[2]/div/form/div[1]/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/div/div/div[2]/div/form/div[1]/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/div/div/div[2]/div/form/div[1]/div/div/input")).sendKeys("admin");
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(); webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[2]/div/div/input")).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")); webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[2]/div/div/input")).clear();
List<WebElement> rows = tbody.findElements(By.className("el-table__row")); webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[2]/div/div/input")).sendKeys("admin");
int size = rows.size(); //点击登录
Assert.assertEquals(6, size); webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[3]/div/button/span")).click();
} catch (Exception | Error e) { }
file();
Assert.fail(e.getMessage()); @Test(description = "新增会议室成功")
} public void insertMeetSuccess() {
} meetManage();
//点击新增按钮
@Test(description = "查询人数,输入负号") webDriver.findElement(By.className("from_button_item")).findElement(By.tagName("button")).findElement(By.tagName("span")).click();
public void findUnNumber() { //新增/编辑框
try { WebElement form = webDriver.findElement(By.className("el-dialog__body")).findElement(By.tagName("form"));
//容纳人数查询 List<WebElement> requireds = form.findElements(By.cssSelector(".el-form-item.is-required"));
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(); for (WebElement required : requireds) {
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(); String text = required.findElement(By.className("el-form-item__label")).getText();
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("-"); if ("会议室名称:".equals(text)) {
String text = webDriver.findElement(By.className("el-message__content")).getText(); required.findElement(By.tagName("input")).click();
Assert.assertEquals("请输入数字", text); required.findElement(By.tagName("input")).clear();
//点击新增 required.findElement(By.tagName("input")).sendKeys("test");
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(); if ("会议室地址:".equals(text)) {
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[3]/div/div/input")).clear(); required.findElement(By.tagName("input")).click();
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[3]/div/div/input")).sendKeys("-"); required.findElement(By.tagName("input")).clear();
String text1 = webDriver.findElement(By.className("el-message__content")).getText(); required.findElement(By.tagName("input")).sendKeys("test1");
Assert.assertEquals("请输入数字", text1); }
} catch (Exception | Error e) { if ("容呐人数:".equals(text)) {
file(); required.findElement(By.tagName("input")).click();
Assert.fail(e.getMessage()); required.findElement(By.tagName("input")).clear();
} required.findElement(By.tagName("input")).sendKeys("100");
} }
if ("规模:".equals(text)) {
//按会议室名称模糊查询 required.findElement(By.className("el-select")).click();
@Test(description = "会议室模糊查询") WebElement div = webDriver.findElement(By.xpath("/html/body/div[4]"));
public void findMeetName() { List<WebElement> lis = div.findElement(By.tagName("ul")).findElements(By.tagName("li"));
try { for (WebElement li : lis) {
String test; WebElement span = li.findElement(By.tagName("span"));
//会议室名称查询 if ("小型会议室".equals(span.getText())) {
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(); span.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.className("el-dialog__footer")).findElement(By.tagName("span")).findElement(By.cssSelector(".el-button.el-button--primary")).findElement(By.tagName("span")).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")).sendKeys("G"); }
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();
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 (text.indexOf("G") != (-1)) {
test = "查询成功";
} else {
test = "查询失败";
} }
Assert.assertEquals("查询成功", test);
} }
} catch (Exception | Error e) {
file();
Assert.fail(e.getMessage());
}
}
//按容纳人数精准查询
@Test(description = "容纳人数精准查询")
public void findNumberMeet() {
try {
String test;
//容纳人数查询
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[4]/button[1]/span")).click();
preciseQuery(".el-table_2_column_12.el-table__cell", "130");
} catch (Exception | Error e) {
file();
Assert.fail(e.getMessage());
} }
} }
@Test(description = "按照会议室规模查询") @Test(description = "修改会议室成功")
public void findScaleMeet() { public void updateMeetSuccess() {
try { WebElement tbody = webDriver.findElement(By.tagName("tbody"));
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")); List<WebElement> trs = tbody.findElements(By.tagName("tr"));
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(); for (WebElement tr : trs) {
webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div[1]/ul/li[1]/span")).click(); String text = tr.findElement(By.cssSelector(".el-table_2_column_11.el-table__cell")).findElement(By.className("cell")).getText();
find.click(); if ("test".equals(text)) {
preciseQuery(".el-table_2_column_11.el-table__cell", "小型会议室"); List<WebElement> buttons = tr.findElement(By.cssSelector(".el-table_2_column_16.el-table__cell")).findElement(By.className("cell")).findElements(By.tagName("button"));
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(); for (WebElement button : buttons) {
webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div[1]/ul/li[2]/span")).click(); WebElement span = button.findElement(By.tagName("span"));
find.click(); if ("修改".equals(span.getText())) {
preciseQuery(".el-table_2_column_11.el-table__cell", "中型会议室"); span.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(); WebElement form = webDriver.findElement(By.className("el-dialog__body")).findElement(By.tagName("form"));
find.click(); List<WebElement> requireds = form.findElements(By.cssSelector(".el-form-item.is-required"));
preciseQuery(".el-table_2_column_11.el-table__cell", "大型会议室"); for (WebElement required : requireds) {
} catch (Exception | Error e) { String text1 = required.findElement(By.className("el-form-item__label")).getText();
file(); if ("会议室名称:".equals(text1)) {
Assert.fail(e.getMessage()); required.findElement(By.tagName("input")).click();
} required.findElement(By.tagName("input")).clear();
} required.findElement(By.tagName("input")).sendKeys("testing");
}
@Test(description = "所有条件查询会议室") if ("会议室地址:".equals(text1)) {
public void findMeet() { required.findElement(By.tagName("input")).click();
try { required.findElement(By.tagName("input")).clear();
String test; required.findElement(By.tagName("input")).sendKeys("testing1");
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(); if ("容呐人数:".equals(text1)) {
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"); required.findElement(By.tagName("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")).click(); required.findElement(By.tagName("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(); required.findElement(By.tagName("input")).sendKeys("200");
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(); if ("规模:".equals(text1)) {
webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div[1]/ul/li[2]/span")).click(); required.findElement(By.className("el-select")).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 div = webDriver.findElement(By.xpath("/html/body/div[4]"));
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> lis = div.findElement(By.tagName("ul")).findElements(By.tagName("li"));
List<WebElement> rows = tbody.findElements(By.className("el-table__row")); for (WebElement li : lis) {
for (WebElement row : rows) { WebElement span1 = li.findElement(By.tagName("span"));
String name = row.findElement(By.cssSelector(".el-table_2_column_9.el-table__cell")).getText(); if ("中型会议室".equals(span1.getText())) {
String number = row.findElement(By.cssSelector(".el-table_2_column_12.el-table__cell")).getText(); span1.click();
String scale = row.findElement(By.cssSelector(".el-table_2_column_11.el-table__cell")).getText(); webDriver.findElement(By.className("el-dialog__footer")).findElement(By.tagName("span")).findElement(By.cssSelector(".el-button.el-button--primary")).findElement(By.tagName("span")).click();
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());
}
}
//新增会议室
@Test(description = "会议室新增测试")
public void insertMeet() {
try {
//点击新增
webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/button/span")).click();
popUp("test", "test1", "100");
//选择规模
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[1]/span")).click();
//点击保存
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());
} }
} }
//新增null错误提示 @Test(description = "删除会议室成功")
@Test(description = "新增null会议") public void deleteMeetSuccess(){
public void insertNullMeetFail() { WebElement tbody = webDriver.findElement(By.tagName("tbody"));
try { List<WebElement> trs = tbody.findElements(By.tagName("tr"));
//点击新增 for (WebElement tr : trs) {
webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/button/span")).click(); String text = tr.findElement(By.cssSelector(".el-table_2_column_11.el-table__cell")).findElement(By.className("cell")).getText();
//点击保存 if ("testing".equals(text)){
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[3]/span/button[2]/span")).click(); List<WebElement> buttons = tr.findElement(By.cssSelector(".el-table_2_column_16.el-table__cell")).findElement(By.className("cell")).findElements(By.tagName("button"));
Thread.sleep(100); for (WebElement button : buttons) {
String text = webDriver.findElement(By.className("el-message__content")).getText(); WebElement span = button.findElement(By.tagName("span"));
Assert.assertEquals("请填写具体信息", text); if ("删除".equals(span.getText())){
//必填内容提示信息 span.click();
String name = webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[1]/div/div[2]")).getText(); List<WebElement> button1s = webDriver.findElement(By.className("el-message-box__btns")).findElements(By.tagName("button"));
String address = webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[2]/div/div[2]")).getText(); for (WebElement button1 : button1s) {
String number = webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[3]/div/div[2]")).getText(); WebElement span1 = button1.findElement(By.tagName("span"));
String scale = webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/form/div[4]/div/div[2]")).getText(); if ("确定".equals(span1.getText())){
Assert.assertEquals("请输入会议室名称", name); span1.click();
Assert.assertEquals("请输入会议室地址", address); }
Assert.assertEquals("请输入容纳人数", number);
Assert.assertEquals("请输入会议室规模", scale);
} catch (Exception | Error e) {
file();
Assert.fail(e.getMessage());
}
}
@Test(description = "新增错误会议室")
public void insertErrorMeet() {
try {
//点击新增
webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div/div[1]/button/span")).click();
popUp("test", "test1", "-qwe123");
//选择规模
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[1]/span")).click();
//点击保存
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 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");
//修改规模
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[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();
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 deleteMeet() {
try {
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 ("testing".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();
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[3]/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());
} }
} }
......
conferenceRoomTest.url=123.60.53.83 conferenceRoomTest.url=http://123.60.53.83/#/beforeMeeting
\ No newline at end of file \ No newline at end of file
...@@ -2,27 +2,17 @@ ...@@ -2,27 +2,17 @@
<suite name="testng"> <suite name="testng">
<listeners> <listeners>
<!-- <listener class-name="com.vimalselvam.testng.listener.ExtentTestNgFormatter"/>-->
<listener class-name="com.tykj.selenium.extentsreport.ExtentTestNGIReporterListener"/> <listener class-name="com.tykj.selenium.extentsreport.ExtentTestNGIReporterListener"/>
<!-- 以上listener在为了让测试报告样式css能够重新加载而写的java类-->
</listeners> </listeners>
<test name="test"> <test name="test">
<classes> <classes>
<class name="com.tykj.selenium.conferenceRoomTest.ConferenceActive"/> <class name="com.tykj.selenium.conferenceRoomTest.ConferenceActive"/>
<methods> <methods>
<include name="resetTest"/> <include name="login"/>
<include name="findUnNumber"/> <include name="insertMeetSuccess"/>
<include name="findMeetName"/> <include name="updateMeetSuccess"/>
<include name="findNumberMeet"/> <include name="deleteMeetSuccess"/>
<include name="findScaleMeet"/>
<include name="findMeet"/>
<include name="insertMeet"/>
<include name="insertNullMeetFail"/>
<include name="insertErrorMeet"/>
<include name="updateErrorMeet"/>
<include name="updateMeet"/>
<include name="deleteMeet"/>
</methods> </methods>
</classes> </classes>
</test> </test>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论