kumar_perlaa
13 years agoContributor
TestComplete Strange Behaviour-- Object/variable is not getting global scope when i tried to access in multiple units...
TestComplete Strange Behaviour
Can you please help me out regarding below issue:
Problem Scenario: ( All methods are defined in same unit)
Code Snippet:
var ContractToRef,TargetExp_IsRef_Alog_Table;à Global Variables
var ContrToRefSel = "TRUE";
function ConfMGR_TTE_VolatilityUpdates(/*ContrToRefSel,isRef,Algorithm,RefExpires*/)
{
TargetExp_IsRef_Alog_Table = ContractToRef.Panel(1).Panel(0).Table("ctl00_cphMain_gvTargetExpiries")
IsRefSelection();
IsAlgorithm();
}
IsRefSelection();
{
var strText = TargetExp_IsRef_Alog_Table.Cell(0,1).innerText; // Global variables are working fine in this method
-----
switch(isRef)
{
case "TRUE":
var isRefObj = TargetExp_IsRef_Alog_Table.FindChild(Array("ObjectType", "RowIndex", "ColumnIndex"),Array("Cell", "1", "1"), 1);
var isRefChild = isRefObj.FindChild("ObjectIdentifier","ctl00_cphMain_gvTargetExpiries_ctl02_chbIsRef",1);
--
if (!isRefChild.checked)
{
isRefChild.ClickChecked(true);
bIsRefSelectionFalg = true;
break;
}
}
IsAlgorithm()
{
var strText = TargetExp_IsRef_Alog_Table.Cell(0,2).innerText;-à Here Iam getting String name as “XYZ”, That mean I am getting global scope of TargetExp_IsRef_Alog_Table variable/object
....
Case “Manual”:
var TotalRows = TargetExp_IsRef_Alog_Table.RowCount;-à Getting error message here and Global variable does not holding address of the object that’s the reason I am getting rows value as null.
----
Log.Message(Total_Rows);
for (var i = 1; i <= TotalRows-1; i++)
{
---------;
-----;
}
----;
}
Can you please help me out regarding below issue:
Problem Scenario: ( All methods are defined in same unit)
The Main function is invoking IsRefSelection() and IsAlgorithm() methods.
ContractToRef,TargetExp_IsRef_Alog_Tableà These variables are declared as global and holds the address of object.
When I am accessing “TargetExp_IsRef_Alog_Table” variable in IsRefSelection()method I am getting global scope and everything is working as per the business scenario, but I am not getting global scope in IsAlgorithm() method. What is causing the problem.
I request you to add sample example instead of suggesting TC articles, I had already went through those. It suppose to work as per any programming language syntax.(C++,Java,C#.Net)
Code Snippet:
var ContractToRef,TargetExp_IsRef_Alog_Table;à Global Variables
var ContrToRefSel = "TRUE";
function ConfMGR_TTE_VolatilityUpdates(/*ContrToRefSel,isRef,Algorithm,RefExpires*/)
{
TargetExp_IsRef_Alog_Table = ContractToRef.Panel(1).Panel(0).Table("ctl00_cphMain_gvTargetExpiries")
IsRefSelection();
IsAlgorithm();
}
IsRefSelection();
{
var strText = TargetExp_IsRef_Alog_Table.Cell(0,1).innerText; // Global variables are working fine in this method
-----
switch(isRef)
{
case "TRUE":
var isRefObj = TargetExp_IsRef_Alog_Table.FindChild(Array("ObjectType", "RowIndex", "ColumnIndex"),Array("Cell", "1", "1"), 1);
var isRefChild = isRefObj.FindChild("ObjectIdentifier","ctl00_cphMain_gvTargetExpiries_ctl02_chbIsRef",1);
--
if (!isRefChild.checked)
{
isRefChild.ClickChecked(true);
bIsRefSelectionFalg = true;
break;
}
}
IsAlgorithm()
{
var strText = TargetExp_IsRef_Alog_Table.Cell(0,2).innerText;-à Here Iam getting String name as “XYZ”, That mean I am getting global scope of TargetExp_IsRef_Alog_Table variable/object
....
Case “Manual”:
var TotalRows = TargetExp_IsRef_Alog_Table.RowCount;-à Getting error message here and Global variable does not holding address of the object that’s the reason I am getting rows value as null.
----
Log.Message(Total_Rows);
for (var i = 1; i <= TotalRows-1; i++)
{
---------;
-----;
}
----;
}