joehiatt
14 years agoNew Contributor
Issue converting Javascript to VBscript - "&&&&" to "and" operator not working.
I'm having some difficulty converting some Javascript that I use to check for a 64 bit OS. I keep getting the error message "An exception occurred in the "CheckOS" unit at line 8: Microsoft VBScript runtime error Object doesn't support this property or method: 'TestedApps.firefox" when I attempt to use it with an "if" statement.
I've included the VBscript I'm attempting to use along with the original working Javascript. Could someone please tell me if this is a flaw with my code or with Testcomplete? I am using version 8.70.727.7
VBscript:
Sub CheckOS()
'Check for Windows 64/32 bit and assign the correct path for IE and Firefox Tested Apps.
' Checks if OS is 64 bit and if FireFox Tested App Exists in TC. Then sets tested app path.
if Sys.OsInfo.Windows64bit and TestedApps.firefox <> null then
TestedApps.firefox.Path = "C:\\Program Files (x86)\\Mozilla Firefox\\"
elseIf TestedApps.iexplore <> null then
TestedApps.firefox.Path = "C:\\Program Files\\Mozilla Firefox\\"
'/* Checks if OS is 64 bit and if iexplore Tested App Exists in TC then sets TestedApp Path*/
if Sys.OsInfo.Windows64bit & TestedApps.iexplore <> null then
TestedApps.iexplore.Path = "C:\\Program Files (x86)\\internet explorer\\"
elseIf TestedApps.iexplore <> null then
TestedApps.iexplore.Path = "C:\\Program Files\\internet explorer\\"
'/* Checks if OS is 64 bit and if AcroRd32 Tested App Exists in TC then set TestedApp Path*/
if Sys.OsInfo.Windows64bit & TestedApps.AcroRd32 <> null then
TestedApps.AcroRd32.Path = "C:\\Program Files (x86)\\Adobe\\Reader 9.0\\Reader\\"
elseIf TestedApps.AcroRd32 <> null then
TestedApps.AcroRd32.Path = "C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\"
end if
'
'/*Functions for testing that Path is correct. - Should remain commented out -*/
' TestedApps.iexplore.Run()
' TestedApps.firefox.Run()
Javascript:
/*Check for Windows 64/32 bit and assign
the correct path for IE and Firefox Tested Apps*/
function CheckOS()
{
/* Checks if OS is 64 bit and if firefox Tested App Exists in TC then sets
TestedApp Path*/
if (Sys.OsInfo.Windows64bit && TestedApps.firefox !=null)
{
TestedApps.firefox.Path = "C:\\Program Files (x86)\\Mozilla Firefox\\";
}
else if (TestedApps.firefox !=null)
{
TestedApps.firefox.Path = "C:\\Program Files\\Mozilla Firefox\\";
}
/* Checks if OS is 64 bit and if iexplore Tested App Exists in TC then sets
TestedApp Path*/
if (Sys.OsInfo.Windows64bit && TestedApps.iexplore !=null)
{
TestedApps.iexplore.Path = "C:\\Program Files (x86)\\internet explorer\\";
}
else if (TestedApps.iexplore !=null)
{
TestedApps.iexplore.Path = "C:\\Program Files\\internet explorer\\";
}
/* Checks if OS is 64 bit and if AcroRd32 Tested App Exists in TC then sets
TestedApp Path*/
if (Sys.OsInfo.Windows64bit && TestedApps.AcroRd32 !=null)
{
TestedApps.AcroRd32.Path = "C:\\Program Files (x86)\\Adobe\\Reader 9.0\\Reader\\";
}
else if (TestedApps.AcroRd32 !=null)
{
TestedApps.AcroRd32.Path = "C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\";
}
/*Functions for testing that Path is correct. -
Should remain commented out -*/
//TestedApps.iexplore.Run();
//TestedApps.firefox.Run();
}
I've included the VBscript I'm attempting to use along with the original working Javascript. Could someone please tell me if this is a flaw with my code or with Testcomplete? I am using version 8.70.727.7
VBscript:
Sub CheckOS()
'Check for Windows 64/32 bit and assign the correct path for IE and Firefox Tested Apps.
' Checks if OS is 64 bit and if FireFox Tested App Exists in TC. Then sets tested app path.
if Sys.OsInfo.Windows64bit and TestedApps.firefox <> null then
TestedApps.firefox.Path = "C:\\Program Files (x86)\\Mozilla Firefox\\"
elseIf TestedApps.iexplore <> null then
TestedApps.firefox.Path = "C:\\Program Files\\Mozilla Firefox\\"
'/* Checks if OS is 64 bit and if iexplore Tested App Exists in TC then sets TestedApp Path*/
if Sys.OsInfo.Windows64bit & TestedApps.iexplore <> null then
TestedApps.iexplore.Path = "C:\\Program Files (x86)\\internet explorer\\"
elseIf TestedApps.iexplore <> null then
TestedApps.iexplore.Path = "C:\\Program Files\\internet explorer\\"
'/* Checks if OS is 64 bit and if AcroRd32 Tested App Exists in TC then set TestedApp Path*/
if Sys.OsInfo.Windows64bit & TestedApps.AcroRd32 <> null then
TestedApps.AcroRd32.Path = "C:\\Program Files (x86)\\Adobe\\Reader 9.0\\Reader\\"
elseIf TestedApps.AcroRd32 <> null then
TestedApps.AcroRd32.Path = "C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\"
end if
'
'/*Functions for testing that Path is correct. - Should remain commented out -*/
' TestedApps.iexplore.Run()
' TestedApps.firefox.Run()
Javascript:
/*Check for Windows 64/32 bit and assign
the correct path for IE and Firefox Tested Apps*/
function CheckOS()
{
/* Checks if OS is 64 bit and if firefox Tested App Exists in TC then sets
TestedApp Path*/
if (Sys.OsInfo.Windows64bit && TestedApps.firefox !=null)
{
TestedApps.firefox.Path = "C:\\Program Files (x86)\\Mozilla Firefox\\";
}
else if (TestedApps.firefox !=null)
{
TestedApps.firefox.Path = "C:\\Program Files\\Mozilla Firefox\\";
}
/* Checks if OS is 64 bit and if iexplore Tested App Exists in TC then sets
TestedApp Path*/
if (Sys.OsInfo.Windows64bit && TestedApps.iexplore !=null)
{
TestedApps.iexplore.Path = "C:\\Program Files (x86)\\internet explorer\\";
}
else if (TestedApps.iexplore !=null)
{
TestedApps.iexplore.Path = "C:\\Program Files\\internet explorer\\";
}
/* Checks if OS is 64 bit and if AcroRd32 Tested App Exists in TC then sets
TestedApp Path*/
if (Sys.OsInfo.Windows64bit && TestedApps.AcroRd32 !=null)
{
TestedApps.AcroRd32.Path = "C:\\Program Files (x86)\\Adobe\\Reader 9.0\\Reader\\";
}
else if (TestedApps.AcroRd32 !=null)
{
TestedApps.AcroRd32.Path = "C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\";
}
/*Functions for testing that Path is correct. -
Should remain commented out -*/
//TestedApps.iexplore.Run();
//TestedApps.firefox.Run();
}