提交 6466075e authored 作者: mry's avatar mry

完成了登录的已知所有测试

上级 69ae0465
......@@ -7,6 +7,7 @@ import org.apache.commons.io.FileUtils;
import org.openqa.selenium.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.testng.Assert;
import org.testng.Reporter;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
......@@ -70,23 +71,108 @@ public class ConferenceActive {
//登录
@BeforeClass
public void url() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
webDriver.get("http://123.60.53.83/#/beforeMeeting");
webDriver.manage().window().maximize();
}
@Test(description = "null用户名密码")
public void nullLoginFail() {
try {
//点击登录
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[3]/div/button/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 = "null密码")
public void nullPasswordLoginFail() {
try {
Thread.sleep(4000);
//输入用户名
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/div/div/div[2]/div/form/div[1]/div/div/input")).clear();
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/div/div/div[2]/div/form/div[3]/div/button/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 = "null用户名")
public void nullUsernameLoginFail() {
try {
webDriver.navigate().refresh();
//输入密码
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[2]/div/div/input")).click();
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[2]/div/div/input")).clear();
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[2]/div/div/input")).sendKeys("admin");
//点击登录
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[3]/div/button/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 ErrorLoginFail() {
try {
Thread.sleep(4000);
//输入用户名
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/div/div/div[2]/div/form/div[1]/div/div/input")).clear();
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[1]/div/div/input")).sendKeys("lwaegyhk");
//输入密码
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[2]/div/div/input")).click();
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[2]/div/div/input")).clear();
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[2]/div/div/input")).sendKeys("iuwaylgthkj");
//点击登录
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[3]/div/button/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 login() {
//输入用户名
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/div/div/div[2]/div/form/div[1]/div/div/input")).clear();
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/div/div/div[2]/div/form/div[2]/div/div/input")).click();
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[2]/div/div/input")).clear();
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[2]/div/div/input")).sendKeys("admin");
//点击登录
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[3]/div/button/span")).click();
try {
Thread.sleep(4000);
//输入用户名
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/div/div/div[2]/div/form/div[1]/div/div/input")).clear();
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/div/div/div[2]/div/form/div[2]/div/div/input")).click();
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[2]/div/div/input")).clear();
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[2]/div/div/input")).sendKeys("admin");
//点击登录
webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div/form/div[3]/div/button/span")).click();
//通过admin判断登录是否成功
String text = webDriver.findElement(By.className("user_out")).findElement(By.className("el-dropdown")).findElement(By.cssSelector(".el-dropdown-link.el-dropdown-selfdefine")).getText();
Assert.assertEquals("admin", text);
} catch (Exception | Error e) {
file();
Assert.fail(e.getMessage());
}
}
@Test(description = "新增会议室成功")
......
......@@ -9,7 +9,13 @@
<classes>
<class name="com.tykj.selenium.conferenceRoomTest.ConferenceActive"/>
<methods>
<include name="nullLoginFail"/>
<include name="nullPasswordLoginFail"/>
<include name="nullUsernameLoginFail"/>
<include name="ErrorLoginFail"/>
<include name="login"/>
<include name="insertMeetSuccess"/>
<include name="updateMeetSuccess"/>
<include name="deleteMeetSuccess"/>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论