Site Loader
Auckland, New Zealand
Selenium WebDriver supports different types of browsers by using its native as well as third party web drivers. Firefox browser is natively supported in Selenium Web driver, but for all other browsers, third party web driver are available for Selenium.

Selenium Supported browsers

Selenium supports different types of browsers, such as
  1. Firefox
  2. Chrome
  3. IE
  4. Safari
  5. Opera etc.
Here are the code snippets for Firefox, Chrome and IE Firefox
System.setProperty("webdriver.firefox.bin","F:\\Program Files   (x86)\\Firefox\\Firefox.exe");
WebDriver driver = new FirefoxDriver();
driver.navigate().to("https://www.google.com");
Chrome
System.setProperty("webdriver.chrome.driver","G:\\Lib\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.navigate().to("https://www.google.com");
IE
System.setProperty("webdriver.ie.driver","G:\\Lib\\internetexplorerdriver.exe");
WebDriver driver = new InternetExplorerDriver();
driver.navigate().to("https://www.google.com");
Checkout the complete video from here Please leave your comments and thanks for watching and reading the post !!! Thanks, Karthik KK

Post Author: Karthik kk

9 Replies to “Working with Different browsers in Selenium WebDriver”

  1. Dear Karthik,
    Thanks for the video. It is really helpful.

    Following could be useful for the users
    For opera
    1. Install opera browser latest version
    2. Download and extract the opera driver to the lib directory as in the video
    https://github.com/operasoftware/operachromiumdriver/releases
    3. Add the lib directory to the PATH
    4. Code snippet for Opera
    WebDriver driver = new OperaDriver();
    driver.navigate().to(“https://www.google.com”);

    Note :: You can skip setting the System property when the driver is added to the PATH

    For Safari
    1. Install the Safari web browser
    2. Download safari driver latest version from Selenium download page
    http://www.seleniumhq.org/download/
    3. Click on the downloaded file to install the driver on the browser
    4. Following code snippet can be used
    WebDriver driver = new SafariDriver();
    driver.navigate().to(“https://www.google.com”);

    Code snippet for HTMLUnitDriver
    WebDriver driver = new HTMLUnitDriver();
    driver.navigate().to(“https://www.google.com”);

    1. Do we need to set property for HTmlUnitdriver?. IF so, please let me know. could you elaborate you blog for HtmlUntidriver

  2. PhanthomJS is another headless browser like HTMLUnitDriver

    Steps to run PhanthomJS with Selenium WebDriver.
    1. Download Phanthom JS
    http://phantomjs.org/download.html
    2. Download the phantomjsdriver-1.1.0.jar from
    http://mvnrepository.com/artifact/com.github.detro.ghostdriver/phantomjsdriver/1.1.0
    3. Add the jar file into the classpath
    4. Code snippet
    File file = new File(“E:\\PTL\\selenium\\June2015\\OrangeHRM\\install\\drivers\\phantomjs.exe”);
    System.setProperty(“phantomjs.binary.path”, file.getAbsolutePath());
    WebDriver driver = new PhantomJSDriver();
    driver.get(“http://www.google.com”);

  3. Dear Karthik,
    Firefox driver is not supported by WebDriver now.
    Will you be updating the videos to reflect recent changes in WebDriver 3.x?

    Your Videos are really helpful to the community.

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *