当前位置 博文首页 > 无限迭代中......:功能测试——房屋租赁系统(Selenium IDE)
源代码:https://gitee.com/shentuzhigang/mini-project/tree/master/test-house-rental
管理员:账号 admin,密码 123456
租客:账号 空格,密码 空格
点击左侧菜单栏查看房源列表,任意选择一个房屋点击修改按钮
修改房源信息: 修改租赁价格为 700.0,完成后点击提交
在上面同一位置,添加房源信息
合理化输入房屋 ID、地址、面积、租金、状态选择未租赁,点击提交
点击左侧菜单栏租赁及合同信息选项下的在租列表,选择任一一个合同,点击查看合同,进入合同详情页面
修改合同,每月交租日改为 2,点击修改按钮提交。
点击租金信息下的我要收租选项,选择任一房屋,点击收租查看详情
点击菜单栏租客已缴租金,输入姓名李四,查询租客信息
点击退出登录按钮,测试结束
// Generated by Selenium IDE
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.core.IsNot.not;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Alert;
import org.openqa.selenium.Keys;
import java.util.*;
import java.net.MalformedURLException;
import java.net.URL;
public class Test1Test {
private WebDriver driver;
private Map<String, Object> vars;
JavascriptExecutor js;
@Before
public void setUp() {
driver = new ChromeDriver();
js = (JavascriptExecutor) driver;
vars = new HashMap<String, Object>();
}
@After
public void tearDown() {
driver.quit();
}
@Test
public void test1() {
driver.get("http://114.215.176.95:60513/text2/");
driver.manage().window().setSize(new Dimension(1552, 840));
driver.findElement(By.name("username")).click();
driver.findElement(By.name("username")).sendKeys("admin");
driver.findElement(By.name("password")).sendKeys("123456");
driver.findElement(By.id("login-button")).click();
driver.findElement(By.cssSelector(".container")).click();
driver.findElement(By.linkText("房源列表")).click();
driver.findElement(By.cssSelector("tr:nth-child(3) .link-update")).click();
driver.findElement(By.id("price")).click();
driver.findElement(By.id("price")).sendKeys("700.0");
driver.findElement(By.cssSelector(".btn-primary")).click();
driver.findElement(By.linkText("添加房源")).click();
driver.findElement(By.id("houseid")).click();
driver.findElement(By.id("houseid"))..sendKeys("a10086");
driver.findElement(By.id("address")).click();
driver.findElement(By.id("address")).sendKeys("615黄记煌三汁焖锅");
driver.findElement(By.id("area")).click();
driver.findElement(By.id("area")).sendKeys("1000000000000000000000000000000000000000000000000000000000000");
driver.findElement(By.id("price")).click();
driver.findElement(By.id("price")).sendKeys("700.0");
driver.findElement(By.cssSelector("tr:nth-child(5) > td")).click();
driver.findElement(By.id("status")).click();
{
WebElement dropdown = driver.findElement(By.id("status"));
dropdown.findElement(By.xpath("//option[. = '未租赁']")).click();
}
driver.findElement(By.id("status")).click();
driver.findElement(By.cssSelector(".btn-primary")).click();
driver.findElement(By.linkText("在租列表")).click();
driver.findElement(By.linkText("查看合同")).click();
driver.findElement(By.name("hetong")).click();
driver.findElement(By.cssSelector(".btn-primary")).click();
driver.findElement(By.cssSelector("tr:nth-child(10)")).click();
driver.findElement(By.id("payday")).sendKeys(