How to get System OS, Browser name and Version using Java and Selenium WebDriver ?

package TechLearndotin;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
import com.thoughtworks.selenium.Selenium;

         public class Browsernameversionosname {
         public WebDriver driver;
         public Selenium selenium;

@Test    // Print Browser name, browser version and OS name
         public void printBrowerNameandVersionNameandOSName2() throws Exception  
         {
        driver.get("http://techlearn.in");
        String s = (String) ((JavascriptExecutor) driver).executeScript("return navigator.userAgent;");
        System.out.println("Browser name : " + s);

        }
    
@BeforeTest
        public void beforeTest()
        {
        driver=new FirefoxDriver();
        driver.manage().window().maximize();
        }

@AfterTest
       public void afterTest()
      {
      }
      }

 
 

Tags: