(一)我编写的测试用例,会将其一步步转化成脚本
插图(由于测试用例跟新了,此处就不贴了,我会在下面详细讲每个脚本的作用)
(二)自动化脚本编写,与测试用例相对应
1.注册模块(HIL01-001)
注意下面将By by 和findElement方法进行了封装,你们也可以判断一下文本框是否可用之类的,在这儿,我省略了
package com.siteTest;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class siteTest {
public WebDriver driver;
@Test
public void showBaidu(){
System.setProperty("webdriver.chrome.driver", "D:\\chromedriver_2.38\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("公司网站");
}
@Test(dependsOnMethods={"showBaidu"})
//用例HIL01-001,注册模块
public void zhuce(){
findEle(byStr("xpath","//*[@id='app']/div/div/div[1]/div/div[2]/div[3]/div[1]")).click();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-