这是我的类的结构:
package com.gex.base.helper;
public class InitializeDriver extends BrowserFactory
{
HashMap<String, String> authenticationMap;
@Factory(dataProvider="authentication", dataProviderClass=DataProviderList.class)
public InitializeDriver(String userName, String uPassword)
{
authenticationMap=new HashMap<String, String>();
authenticationMap.put("UserName", userName);
authenticationMap.put("Password", uPassword);
}
@BeforeTest
public void Gexlogin()
{
LoginPF objLogin=PageFactory.initElements(BrowserFactory.driver, LoginPF.class);
System.out.println("Logging into GEx");
objLogin.loginToDGEx(authenticationMap.get("UserName"), authenticationMap.get("Password"));
System.out.println("Successfully Logged into GEx");
}
@AfterTest
public void directLogout(){
// logout from application
LogoutPF objLogoutTest = PageFactory.initElements(BrowserFactory.driver, LogoutPF.class);
objLogoutTest.LogOffGEx();
extent.flush();
driver.close();
}
}
LoginToGEx是另一个类中的函数,例如:
public void loginToGEx(String strUsername, String strPassword)
{
username.sendKeys(strUsername)
password.sendKeys(strPassword);
loginButton.click();
System.out.println("Successfully Logged into GEx");
}
DataProviderClass
public class DataProviderList {
@DataProvider(name="authentication")
public static Object[][] authentication()
{
return new Object[][] {
{"abc", "123"},
{"xyz", "456"},
};
}
}
尚方宝剑之说
相关分类