测试方法如下:
packagecom.test.java;
importjava.io.File;
importjava.io.IOException;
importjxl.read.biff.BiffException;
importorg.openqa.selenium.WebDriver;
importorg.openqa.selenium.firefox.FirefoxDriver;
importorg.openqa.selenium.support.PageFactory;
importorg.testng.annotations.Test;
publicclasstestLogin2 {
//我的所有代码在此路径下D:\Eclipse Script\TestNG\src\com\test\java
// TestNG为Project Name,abc.xls存放在TestNG文件夹下
FilefileName=newFile("abc.xls");
@Test
publicvoidtestLogin()throwsBiffException, IOException
{
WebDriver driver=newFirefoxDriver();
login m=PageFactory.initElements(driver, login.class);
//读取abc.xls问价的第二行的所有数据,将第一列的值作为登录邮箱的的用户名
//第二列的值作为登录邮箱的密码
String[] list = ExcelReader.readExcel(fileName,1);
m.login(driver,list[0],list[1]);
}
}
abc.xml文件的内容为:
username | password |
justForYourTesting | 135135 |
注:原创作品 转载请注明出处。