How to Get Browser Name Using JavascriptExecutor Selenium?

Get Browser Name Using JavascriptExecutor

package com.selenium.mix;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class GetBrowserName
   public static void main(String[] args) 
      WebDriver driver=new FirefoxDriver();
      JavascriptExecutor js = (JavascriptExecutor) driver;
      System.out.println(js.executeScript("return navigator.appCodeName"));

I love open-source technologies and am very passionate about software development. I like to share my knowledge with others, especially on technology that's why I have given all the examples as simple as possible to understand for beginners. All the code posted on my blog is developed, compiled, and tested in my development environment. If you find any mistakes or bugs, Please drop an email to, or You can join me on Linkedin.

Leave a Comment