DEV Community

Cover image for πŸš€ Day 27 of My Automation Journey – Introduction to Selenium & Maven Setup
bala d kaveri
bala d kaveri

Posted on

πŸš€ Day 27 of My Automation Journey – Introduction to Selenium & Maven Setup


Today marks a big milestone in my automation journey 🎯

Till now, I was learning core Java logic
πŸ‘‰ Today, I stepped into real automation using Selenium

This is where things get exciting πŸ”₯


πŸ”Ή 1. What is Selenium?

πŸ‘‰ Selenium is a tool used for automating web browsers

That means:

  • Opening a browser 🌐
  • Navigating websites
  • Clicking buttons
  • Filling forms
  • Validating UI

πŸ’‘ In simple terms:

πŸ‘‰ If you can do it manually in a browser, Selenium can automate it.


πŸ”Ή 2. Why Selenium?

βœ” Saves time ⏱
βœ” Reduces manual effort
βœ” Useful for testing & automation
βœ” Industry standard tool


πŸ”Ή 3. Setting Up Selenium using Maven

Instead of downloading jars manually, we use Maven πŸ“¦

πŸ‘‰ Maven helps manage:

  • Dependencies
  • Versions
  • Project structure

πŸ”Ή 4. Understanding pom.xml File

This is the heart of a Maven project ❀️

πŸ’» Sample pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0">

    <modelVersion>4.0.0</modelVersion>

    <groupId>Selenium1</groupId>
    <artifactId>Selenium1</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.18.1</version>
        </dependency>

    </dependencies>

</project>
Enter fullscreen mode Exit fullscreen mode

πŸ” Explanation (Important πŸ”₯)

🧠 Project Info:

  • groupId β†’ Project/company name
  • artifactId β†’ Project name
  • version β†’ Current version

βš™οΈ Properties:

<maven.compiler.source>17</maven.compiler.source>
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Defines Java version


πŸ“¦ Dependencies:

<dependency>
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ This is where we add external libraries


πŸ”Ή 5. How to Add Dependency from Maven Repository

πŸ‘‰ Go to: mvnrepository.com

Steps:

  1. Search β†’ selenium-java
  2. Select latest version
  3. Copy dependency
  4. Paste inside <dependencies>

πŸ’‘ Why this is important?

πŸ‘‰ Instead of manual setup, Maven automatically:

  • Downloads jars
  • Manages versions
  • Handles conflicts

πŸ”Ή 6. Creating Selenium Setup

Once dependency is added βœ…

πŸ‘‰ Maven will download everything automatically

Now we are ready to write our first automation program πŸš€


πŸ”Ή 7. First Selenium Program

package first;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class First {

    public static void main(String[] args) {

        ChromeDriver driver = new ChromeDriver();
        driver.get("https://google.com");

    }
}
Enter fullscreen mode Exit fullscreen mode

πŸ” Logic Explained:

  • ChromeDriver β†’ launches Chrome browser
  • driver.get() β†’ opens website

πŸ‘‰ That’s it! Your first automation script πŸŽ‰


⚠️ Important Notes:

βœ” ChromeDriver should match browser version
βœ” Browser will open automatically
βœ” Close using driver.quit()


πŸ”Ή8. 🌐 Browsers Supported by Selenium

Selenium supports multiple browsers using specific drivers πŸ‘‡

βœ… Browser / Driver Mapping

Browser Driver
Google Chrome ChromeDriver
Mozilla Firefox GeckoDriver
Microsoft Edge EdgeDriver
Safari SafariDriver
Internet Explorer IEDriverServer
Opera OperaDriver
Chromium ChromeDriver
Brave ChromeDriver
Vivaldi ChromeDriver

πŸ’‘ Key Insight:

πŸ‘‰ Most modern browsers are Chromium-based

πŸ‘‰ So they work using ChromeDriver


πŸ”Ή9. πŸ’» Operating Systems Supported by Selenium

Selenium is cross-platform and works across multiple environments πŸ‘‡

βœ… OS / Support Type

Operating System Support
Windows Supported
macOS Supported
Linux Supported
Unix Supported

πŸ”§ Extended Environment Support

Environment Support
Docker Supported
Jenkins (CI/CD) Supported
GitHub Actions Supported
AWS / Azure / GCP Supported

πŸ’‘ Key Insight:

πŸ‘‰ Selenium scripts can run on any OS where browser + driver is available

πŸ‘‰ This enables:
βœ” Cross-browser testing

βœ” Cross-platform automation

βœ” Scalable test execution πŸš€

πŸ”Ή 10. Real-World Use Cases

πŸ‘‰ Login automation
πŸ‘‰ Form submissions
πŸ‘‰ Testing UI flows
πŸ‘‰ Web scraping (basic level)


πŸ”š Final Takeaways

βœ” Selenium = Browser Automation
βœ” Maven = Dependency Management
βœ” pom.xml = Project configuration
βœ” Easy setup using Maven repository
βœ” First step into real automation πŸš€


πŸ€– A Small Note
I used ChatGPT to help structure and refine this blog while keeping the concepts aligned with my learning.

Top comments (0)