What is the fastest way to determine the OS of the SUT?

What is the fastest way to determine the OS of the SUT? It seems to me there should be a set of system properties, but I can't find a reference to them anywhere.

Thanks.
-dave

Comments

  • I want to do something like this:

    If system.OS = "windows" Then...
    Else
    If system.OS = "OSX" Then...

    That would be a lot faster than searching for the start button or the Apple icon.
  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    Searching for the Apple icon (or the Windows Start menu) is the recommended way to do this. The search really doesn't take very long, and only needs to be done once at the beginning of your script if you then set a global variable based on what you find (you can even call it system if you like ;-)):
    global system
    if imageFound("AppleIcon") then set system.OS to "OSX"
    else if imageFound("StartMenu") then set system.OS to "Windows"
    else set system.OS to "Unknown"
    
  • Thanks Doug... I'll try the code you posted.
    -dave
  • Hi again Doug,
    I tried something like this using universal variables but, was unable to access the variable from other scripts in the other suites or scripts within the same suite.

    Am I required to set the evaluationContext to "universal" in each script, or should this be handled simply by declaring the variables as universal? Or should I use properties as you suggested above to avoid this problem?

    so currently the script Main says
    universal SUTOS, .. blah blah
    
    if blah blah 
    then put "OSX" into SUTOS
     
    if blah blah blah
    then put "Windows" into SUTOS
    
    

    and the script DoSomeThing in the same suite says...
    if SUTOS is "OSX"
    then blah
    
    if SUTOS is "Windows" 
    then blah
    
    

    But, the value of SUTOS is not being passed to the script DoSomeThing. Can you help me out here?

    Thanks.
    -dave
  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    You need to declare universal (or global) variables in each script or handler where you use them. So your second script should look like this:
    universal SUTOS
    
    if SUTOS is "OSX" 
    then blah 
    
    if SUTOS is "Windows" 
    then blah 
    
    or else like this:
    if universal SUTOS is "OSX" 
    then blah 
    
    if universal SUTOS is "Windows" 
    then blah 
    
    (The evaluationContext is a rather obscure global property that only affects the way undeclared variables are interpreted within a do or send command or a merge function. It is very rarely used, and not relevant in this case.)
Sign In or Register to comment.