Mk1
8 years agoOccasional Contributor
Hi SmartBear Team,How do i convert a string from property file to an Object? eval is not helping.
'undefined' is null or not an object
this is the value i'm reading from my property file
genericAuthButton=Sys.Browser("iexplore").Page(Project.Variables.pPage).Object("app").PowerCardV3_1("app").HDividedBox("hdividedbox1").CustomTitleWindow("home").P7_autho_period(0).Form(0).Canvas("IDENTIFICATION");
below happens in my script
var genButPath = context.get("genericAuthButton");
var localBtnPath = eval(genButPath);
var periodCode = localBtnPath;
periodCode.TextInput("period_codeTI").Keys(context.get("PeriodCode"));
You can still test your scenario with the below code
function test()
{
doStuff(context.get("genericAuthButton"));
}
function doStuff(genButPath)//Pass your hasp map string value { var localBtnPath = eval(genButPath);//here your genButPath shouold be your Object FullName if(localBtnPath.Exists) { localBtnPath.TextInput("period_codeTI").Keys(context.get("PeriodCode")); } else { Log.Error("Object not exists for the Fullname" + genButPath); } }