WebDriver - Launching a Browser
You can use the below syntax to launch a browser:
WebDriver driver = new FirefoxDriver();
In above syntax:
1. WebDriver is a predefined imported Class from “open.openqa.selenium”.
2. driver: Name of the new object created, it is “driver” id object of WebDriver Class.
3. In order to create an object of specified class, “new” java keyword is used.
4. FirefoxDriver is a predefined Class. FirefoxDriver() is a predefined statement which is calling constructor.
Couple of more examples:
WebDriver driver = new ChromeDriver();
WebDriver driver = new InternetExplorerDriver();
Few more links to help you with opening a browser:
How to open specific browser using selenium WebDriver? [Link]
How to launch Firefox, Internet Explorer, Chrome and Safari using Selenium WebDriver? [Link]
How to open multiple browsers using WebDriver? [Link]
Also see:
WebDriver: Close a Browser Tab
Closing the browser window at the end of Selenium test
WebDriver - Open a new tab