1 Reply Latest reply: Apr 24, 2014 6:55 AM by mctr RSS

    How to get IE version with in Openscript?

    Manish Bhatla-Oracle

      Is there any way to find out browser version (i.e. launched using browser.launch())  from open script. Basically i need if browser is IE8 or IE9 or any other?

        • 1. Re: How to get IE version with in Openscript?
          mctr

          import java.util.regex.Matcher;

          import java.util.regex.Pattern;

          import java.io.BufferedReader;

          import java.io.FileInputStream;

          import java.io.InputStreamReader;

           

          public String getIEVersion()   throws Exception {

           

           

            ArrayList<String> output = new ArrayList<String>();

            Process p = Runtime.getRuntime().exec("reg query \"HKLM\\Software\\Microsoft\\Internet Explorer\" /v Version");

            BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()),8*1024);

            BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));

            String s = null;

            while ((s = stdInput.readLine()) != null)

            output.add(s);

            String internet_explorer_value = (output.get(2));

            String version = internet_explorer_value.trim().split("   ")[2];

            System.out.println("Full IE version is:" + version);

           

           

            Pattern pp = Pattern.compile("(^[^\\d]*(\\d+))");

            Matcher m = pp.matcher(version);

            if (m.find()) {

            System.out.println("IE version is:" + m.group(2));

            }

            return m.group(2);

              

            }