提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
MyOffice功能测试
功能测试简介
功能测试就是对产品的各功能进行验证,根据功能测试用例,逐项测试,检查产品是否达到用户要求的功能。
提示:以下是本篇文章正文内容,下面案例可供参考
一、 打开浏览器输入网站
网址:http://114.215.176.95:60503/goodmanage/index.jsp
输入系统管理员们 》账号:zhangsan》密码:123456
二、步骤
1.点击左侧“商品管理-商品添加”
进入商品信息添加模块,输入商品名称,价格,描述,数量信息进行商品信息添加,点击提交按钮。
建议使用xpath定位
2.点击左侧“商品查询”按钮
进入商品信息查询页面,输入商品ID,点击查询按钮
3.完成之后退出系统
总结和成绩
> 完整代码 ,别忘了~~一键三连支持一下,原创不易AQA
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
public class Example {
// Mooctest Selenium Example
// <!> Check if selenium-standalone.jar is added to build path.
public static void test(WebDriver driver) throws InterruptedException {
// TODO Test script
// eg:driver.get("https://www.baidu.com/")
// eg:driver.findElement(By.id("wd"));
driver.get("http://114.215.176.95:60503/goodmanage/index.jsp");
driver.manage().window().maximize();
Thread.sleep(1000);
driver.findElement(By.id("userName")).sendKeys("zhangsan");
driver.findElement(By.id("password")).sendKeys("123456");
driver.findElement(By.id("btnLogin")).click();
driver.switchTo().frame(1);
Thread.sleep(1000);
driver.findElement(By.cssSelector("#menuTree > div > div:nth-child(4) > div:nth-child(1) > span:nth-child(3) > a")).click();
driver.findElement(By.cssSelector("#menuTree > div > div:nth-child(4) > div:nth-child(2) > div > span:nth-child(3) > a")).click();
driver.switchTo().defaultContent();
Thread.sleep(1000);
driver.switchTo().frame(2);
driver.findElement(By.xpath("//*[@id=\"productName\"]")).sendKeys("1");
Thread.sleep(1000);
{
WebElement element = driver.findElement(By.id("productPrice"));
Actions builder = new Actions(driver);
builder.doubleClick(element).perform();
}
driver.findElement(By.xpath("//input[@id='productPrice']")).sendKeys("12");
Thread.sleep(1000);
{
WebElement element = driver.findElement(By.id("description"));
Actions builder = new Actions(driver);
builder.doubleClick(element).perform();
}
driver.findElement(By.xpath("//input[@id='description']")).sendKeys("good");
Thread.sleep(1000);
{
WebElement element = driver.findElement(By.xpath("//input[@id='productNumber']"));
Actions builder = new Actions(driver);
builder.doubleClick(element).perform();
}
Thread.sleep(1000);
driver.findElement(By.xpath("//input[@id='productNumber']")).sendKeys("1");
driver.findElement(By.cssSelector(".cmdField:nth-child(1)")).click();
driver.switchTo().defaultContent();
driver.switchTo().frame(1);
driver.findElement(By.cssSelector("#menuTree > div > div:nth-child(4) > div:nth-child(3) > div > span:nth-child(3) > a")).click();
driver.switchTo().defaultContent();
Thread.sleep(1000);
driver.switchTo().frame(2);
driver.findElement(By.xpath("//input[@name='productID']")).sendKeys("1");
{
WebElement element = driver.findElement(By.xpath("//input[@name='productName']"));
Actions builder = new Actions(driver);
builder.doubleClick(element).perform();
}
driver.findElement(By.xpath("//input[@name='productName']")).sendKeys("iPhone5s");
Thread.sleep(1000);
driver.findElement(By.xpath("//input[@value='查询']")).click();
driver.switchTo().defaultContent();
driver.switchTo().frame(0);
driver.findElement(By.xpath("//*[@id=\"HyperLink3\"]")).click();
}
public static void main(String[] args) {
// Run main function to test your script.
WebDriver driver = new ChromeDriver();
try {
test(driver);
} catch (Exception e) {
e.printStackTrace();
} finally {
driver.quit();
}
}
}