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

    Selenium

    Learning Selenium WebDriver

    Introduction

    Selenium Webdriver is a set of API’s that automates browsers. Primarily, it is used for automating web applications for Functional Testing purposes. Learning Selenium is easy.

    In this post we will set up java, eclipse, and selenium to run a sample program in Selenium.

    Prerequisites: Windows or Linux Machine

    • Java JDK installation.
    • Eclipse Download.
    • Run a sample selenium program.

     

    Selenium Automation

     

    Java JDK Installation:

    https://www.testingdocs.com/download-and-installing-java-jdk/

    Eclipse Installation:

    https://www.testingdocs.com/downloading-and-extracting-eclipse-ide/

    Create a Maven project.

    Setup and Configuration of Selenium in Eclipse is very easy using Maven. New to Maven?

    Please have a look at: What is Maven ?

    How to create a new maven project.

    File -> New -> Maven Project.

    Create a simple project, choose skip archetype selection. Enter the project name and hit Finish.

    Now we will add Selenium dependency to Our project. Add the below dependencies to pom.xml.

    Eclipse would automatically download the dependencies and builds the workspace automatically.

    Tip: Hit Ctrl+S keyboard combination to save.

     

    <dependencies>
     <dependency>
     <groupId>org.seleniumhq.selenium</groupId>
     <artifactId>selenium-server</artifactId>
     <version>2.53.1</version>
     </dependency>
     
     <dependency>
     <groupId>org.seleniumhq.selenium</groupId>
     <artifactId>selenium-api</artifactId>
     <version>2.53.1</version>
     </dependency>
    
     <dependency>
     <groupId>org.seleniumhq.selenium</groupId>
     <artifactId>selenium-java</artifactId>
     <version>2.53.1</version>
     </dependency>
    
     <dependency>
     <groupId>org.seleniumhq.selenium</groupId>
     <artifactId>selenium-remote-driver</artifactId>
     <version>2.53.1</version>
     </dependency>
    
     <dependency>
     <groupId>org.seleniumhq.selenium</groupId>
     <artifactId>selenium-firefox-driver</artifactId>
     <version>2.53.1</version>
     </dependency>
     
     </dependencies>

     

    You can check the added dependencies and any conflicts, also as shown below.

    Expand the project and right-click pom.xml and open it with Maven POM editor as shown in the picture.

    POM_Editor

     

    Switch to the dependencies tab and click on Add.. button to add a dependency.

    Type selenium in the textbox and hit enter, choose the dependencies you want, and add them to the project. To practice different programs using Selenium choose all the dependencies.

    After adding the dependencies save them.For example, IE Driver maven dependency :

    <dependency>
     <groupId>org.seleniumhq.selenium</groupId>
     <artifactId>selenium-ie-driver</artifactId>
     <version>2.53.1</version>
    </dependency>

    Create a sample Selenium first program

    Create a new class and choose the main method while creating as shown in below figure.

    FirstProgram_Java

     

    Now type the following program code :

    package demo;
     
    import org.openqa.selenium.firefox.FirefoxDriver;
     
    public class FirstProgram {
     
     public static void main(String[] args) {
     
     FirefoxDriver fox = new FirefoxDriver(); 
     fox.get("http://www.google.com"); 
     fox.close();
     
     }
     
    }

     

    Run the program to see Firefox open, Browse Google search engine page and close.

     

    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/

    Save

    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 WebDriver Actions› XPath Tutorial for Automation

    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