Skip to content
Advertisement

How to get browser name using Selenium WebDriver with Java?

I have a test case and need to execute based on the browser name i.e. IE or Chrome. In this test case some part will depend on browser type.

How will I get the browser name in between the execution? Example if it is IE, I need to pass the data. If it is Chrome browser, I need to select the data.

Advertisement

Answer

You can use below code to know browser name, version and OS details:-

JavaScript

packages you need to import

JavaScript

OR

JavaScript

Hope it will help you 🙂

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement