0

i have write automation code for product which i'm currently working on and some functionality is various according to windows version. to tacks those functions i planned to have if loop for windows local and if you have better idea then this means pls update it

Note: i'm beginner Automation testing

  • Please share some of your code and rephrase your question as it is really hard to understand your problem. – J. Tuc Feb 09 '17 at 11:02
  • 1
    Possible duplicate of [Detect Windows version in .net](http://stackoverflow.com/questions/2819934/detect-windows-version-in-net) – ASh Feb 09 '17 at 11:04

4 Answers4

0

You can get the system/environment to get the value for the windows build and version .

AaronBDC
  • 118
  • 8
0

For Windows 8.1+ you can no longer use the OSVersion (it will always show Windows Version 8). Instead you should include an App Manifest and write different scripts based on the targeted environment.

nelsontruran
  • 514
  • 4
  • 18
0

You can read from regsirty through code and do specific action what you intended.

Say for ex:

Registry key you can find here:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion and then look for "ProductName"

You can open registry information by giving regedit.exe in run (windows+r)

 var reg = 
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\WindowsNT\CurrentVersion");

 string productName = (string)reg.GetValue("ProductName");

 if(productName.StartsWith("Windows 10"))
 {
 }
else
 {
 }
Praveen M
  • 443
  • 2
  • 11
0
        //Get Operating system information.
        OperatingSystem os = Environment.OSVersion;
        //Get version information about the os.
        Version vs = os.Version;

        if (vs.Major == 10 && vs.Minor == 0)  // Test flow for WINDOWS 10 environment 
        {
        }
        else if (vs.Major == 6 && vs.Minor == 3)  // Test flow for WINDOWS 8.1 environment 
        {
        }
        else                             // Test flow for WINDOWS 7 and 8 environment  
        {