TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    Selenium

    Working with Different Browsers in Selenium

    In this article, we will learn how to instantiate different browsers that we commonly test using automation. Code snippets to demonstrate the launch of different browsers using selenium webdriver.

    Firefox Browser

    Example code snippet to launch the Firefox browser and open the Twitter website.

    package com.testingdocs.selenium.demo;
    
    import java.util.concurrent.TimeUnit;
    import org.openqa.selenium.firefox.FirefoxDriver;
    
    public class FirefoxDemo {
     
    public static void main(String[] args) {
     FirefoxDriver driver=new FirefoxDriver();
     driver.get("https://www.twitter.com");
     System.out.println("TestingDocs >> Launched Twitter.com Website");
     driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
     driver.quit();
    }
    
    }

     

    Internet Explorer

    Example code snippet to launch Internet Explorer browser and open Facebook website.

    package com.testingdocs.selenium.demo;
    
    import java.util.concurrent.TimeUnit;
    import org.openqa.selenium.ie.InternetExplorerDriver;
    
    public class IEDemo {
     
    public static void main(String[] args) 
     {
     System.setProperty("webdriver.ie.driver","Your_Path_to_IEdriverServer.exe");
     InternetExplorerDriver driver=new InternetExplorerDriver();
     driver.get("https://www.facebook.com");
     System.out.println("TestingDocs >> Launched Facebook Website");
     driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
     driver.quit();
     }
    
    }

     

    Safari Browser

    Example code snippet to launch Safari browser and open LinkedIn website.

    
    
    import java.util.concurrent.TimeUnit;
    import org.openqa.selenium.safari.SafariDriver;
    
    public class SafariDemo {
    
     public static void main(String[] args) {
     SafariDriver driver=new SafariDriver();
     driver.get("https://www.linkedin.com");
     System.out.println("TestingDocs >> Launched LinkedIn Website");
     driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
     driver.quit();
     }
    
    }

     

    Chrome Browser

    Steps to Download  Chrome are listed out here:

    (https://www.testingdocs.com/questions/how-to-download-chrome-browser-on-windows/)

    Example code snippet to launch the Chrome browser and open the MSN website.

    package com.testingdocs.selenium.demo;
    
    import java.util.concurrent.TimeUnit;
    import org.openqa.selenium.chrome.ChromeDriver;
    
    public class ChromeDemo {
     
     public static void main(String[] args) {
     System.setProperty("webdriver.chrome.driver","Your_Path_To_chromedriver.exe");
     ChromeDriver driver=new ChromeDriver();
     driver.get("https://www.msn.com");
     System.out.println("TestingDocs >> Launched Google Website");
     driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
     driver.quit();
     
     }
    
    }

     

    Selenium WebDriver Tutorials on this website can be found at:

    https://www.testingdocs.com/selenium-webdriver-tutorial

    For more details on the Selenium, visit the official website at:

    https://www.selenium.dev/

    Related Posts

    Windows 10 Settings

    Selenium /

    Add Microsoft Webdriver on Windows OS

    Download Selenium Components

    Selenium /

    Getting Started with Selenium Webdriver

    LambdaTest Testing Cloud SaaS Platform

    Selenium /

    LambdaTest – Testing Cloud SaaS Platform

    Selenium /

    Selenium 3.0 and Mozilla GeckoDriver

    SauceLabs Website

    Selenium /

    Run an Example Test on SauceLabs

    ‹ Learning Selenium PageFactory› Selenium3 : Marionette and GeckoDriver Example

    Recent Posts

    • ChatGPT Plans Free and PlusChatGPT Subscription Plans
    • Stellar Converter for Database ToolStellar Converter for Database
    • Stellar MySQL Log AnalyzerStellar Log Analyzer for MySQL
    • Stellar Repair for MySQLStellar Repair for MySQL
    • ChatGPT IntroductionChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI FeaturesChatGPT4 Conversational AI Features
    • Trends in Software EngineeringShaping the Future of Development: Exploring Key Trends in Software Engineering
    • Java PerformanceImproving Java Performance with Multithreading
    • QDrant Vector DatabaseOpen-source Vector Databases
    • Difference between PHP and JavaScript?
    • Bing AI Browser Web ContentBing Conversation Styles
    • ChatGPT PreviewChatGPT Introduction
    • Open Source AI Frameworks TensorFlowOpen Source AI Frameworks
    • Artificial Intelligence Tools

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com