CreatePortfolioTest
package com.qtpselenium.hybrid.SuiteA;
import java.util.Hashtable;
import org.testng.SkipException;
import org.testng.annotations.Test;
import com.qtpselenium.hybrid.BaseTest;
public class CreatePortfolioTest extends BaseTest {
@Test(dataProvider="getData")
public void createPortfolioTest(Hashtable<String, String> data) throws Exception{
if(data.get("RunMode").equals("N")){
throw new SkipException("RunMode is set to N");
}
ds.setEnvProp(envProp);
ds.setProp(prop);
ds.executKeywords(testName, xls,data);
}
}
DriverScript
package com.qtpselenium.hybrid.driverScript;
import java.lang.reflect.Method;
import java.util.Hashtable;
import java.util.Properties;
import com.qtpselenium.hybrid.keywords.ApplicationKeywords;
import com.qtpselenium.hybrid.util.XLS_Reader;
public class DriverScript {
public Properties prop;
public Properties envProp;
ApplicationKeywords app=null;
public void executKeywords(String testName,XLS_Reader xls,Hashtable<String, String>data) throws Exception{
app=new ApplicationKeywords();
app.setEnvProp(envProp);
app.setProp(prop);
int rowCount=xls.getRowCount("Keywords");
//no need of columns as we are checking rows only
for (int rowNum = 2; rowNum <rowCount ; rowNum++) // to read the data from xsl file
{
String tcid=xls.getCellData("Keywords","TCID" , rowNum);
String keyword=xls.getCellData("Keywords", "Keyword", rowNum);
String objectKey=xls.getCellData("Keywords", "Object", rowNum);
String dataKey=xls.getCellData("Keywords", "Data", rowNum);
app.setObjectKey(objectKey);
app.setDataKey(dataKey);
app.setData(data); //passing data to genericKeyword
// printing information from generic keywords
if (tcid.equals(testName)) {
//Reflection API
Method method;
method=app.getClass().getMethod(keyword);
method.invoke(app);
}
}
}
public void setProp(Properties prop) {
this.prop = prop;
}
public void setEnvProp(Properties envProp) {
this.envProp = envProp;
}
}
Instructor
Ashish Thakur Replied on 05/05/2020
There is something wrong in keyword
May be the keyword function is not present