一、功能测试
功能测试
性能测试
兼容性测试
易用性测试
安全测试
二、接口测试
测试登录功能
package com.mall.test;
import org.junit.jupiter.api.Order;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
public class HomePage {
public static WebDriver driver;
@BeforeClass
public void openBrowser() throws InterruptedException {
System.setProperty("webdriver.edge.driver" , "D:/EdgeDriver/msedgedriver.exe");
//打开浏览器
EdgeOptions options = new EdgeOptions();
options.addArguments("--remote-allow-origins=*");
driver = new EdgeDriver(options);
System.out.println(driver);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
Thread.sleep(2000);
driver.get("http://www.localhost:28089");
}
@Test
@Order(8)
public void login(){
driver.manage().window().maximize();
driver.get("http://www.localhost:28089");
driver.findElement(By.xpath("//a[text()='登录']")).click();
driver.findElement(By.xpath("//input[@placeholder='请输入你的手机号']")).clear();
driver.findElement(By.xpath("//input[@placeholder='请输入你的手机号']")).sendKeys("13700002703");
driver.findElement(By.xpath("//input[@placeholder='请输入你的密码']")).clear();
driver.findElement(By.xpath("//input[@placeholder='请输入你的密码']")).sendKeys("123456");
// driver.
}
}
查看商品详情,加购物车,去结算,支付,取消订单
package com.mall.test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class order {
public WebDriver driver;
@BeforeClass
public void openBrowser() {
driver = HomePage.driver;
}
@Test
public void testShop(){
driver.findElement(By.xpath("//*[@id=\"flash\"]/ul/li[1]/a/img")).click();
driver.findElement(By.xpath("//input[@value='加入购物车']")).click();
driver.findElement(By.xpath("//button[text()='确认']")).click();
driver.findElement(By.xpath("//a[contains(text(),'购物车')]")).click();
driver.findElement(By.xpath("//input[@value='去结算']")).click();
driver.findElement(By.xpath("//a[text()='提交订单']")).click();
driver.findElement(By.xpath("//a[text()='去支付']")).click();
driver.findElement(By.xpath("//img[@alt='支付宝']")).click();
driver.findElement(By.xpath("//a[text()='支付成功']")).click();
driver.findElement(By.xpath("//a[text()='取消订单']")).click();
driver.findElement(By.xpath("//button[text()='确认']")).click();
}
}