Getting Started

Loading concept...

Selenium Fundamentals - Getting Started 🚀

The Story of the Robot Helper

Imagine you have a robot friend who can use your computer exactly like you do. It can click buttons, type in boxes, scroll pages, and read what’s on the screen. Now imagine you could teach this robot to do boring, repetitive tasks for you—like filling out 100 forms or checking if 50 web pages work correctly.

That robot is Selenium!


What is Selenium?

The Simple Answer

Selenium is a free tool that lets you control a web browser using code. Instead of clicking with your mouse, you write instructions, and Selenium does the clicking for you.

Real-Life Example

Think of it like this:

You (Manual) Selenium (Automatic)
Open Chrome driver.get("https://google.com")
Click search box driver.find_element(...).click()
Type “cats” element.send_keys("cats")
Press Enter element.submit()

Same actions, but Selenium never gets tired!

Why People Love Selenium

  • âś… Free forever - No license fees
  • âś… Works with all browsers - Chrome, Firefox, Safari, Edge
  • âś… Multiple languages - Python, Java, JavaScript, C#, Ruby
  • âś… Industry standard - Used by Google, Netflix, Amazon
graph TD A[Your Code] --> B[Selenium] B --> C[Browser] C --> D[Website]

WebDriver Architecture

The Messenger System

Think of ordering food at a restaurant:

  1. You (the customer) tell the waiter what you want
  2. The waiter goes to the kitchen
  3. The kitchen prepares your food
  4. The waiter brings it back to you

Selenium works the same way!

Restaurant Selenium
You Your Code
Waiter WebDriver
Kitchen Browser Driver
Food Website Response

The Three Players

graph TD A[Your Test Code] -->|Commands| B[WebDriver API] B -->|HTTP Requests| C[Browser Driver] C -->|Controls| D[Actual Browser] D -->|Results| C C -->|Response| B B -->|Data| A

1. Your Code - The instructions you write

driver.find_element("id", "login")

2. WebDriver - Translates your code into browser commands

3. Browser Driver - The actual robot that controls the browser

JSON Wire Protocol

When you say “click this button,” it becomes a message like:

{
  "action": "click",
  "element": "login-button"
}

This message travels from your code → WebDriver → Browser Driver → Browser.


Browser Driver Setup

What is a Browser Driver?

Each browser needs its own “translator” to understand Selenium commands.

Browser Driver Name
Chrome ChromeDriver
Firefox GeckoDriver
Safari SafariDriver
Edge EdgeDriver

The Old Way (Manual Download)

Before Selenium 4.6, you had to:

  1. Check your browser version
  2. Find matching driver version
  3. Download the correct file
  4. Put it in the right folder
  5. Update PATH or specify location

This was confusing and broke often!

# Old way - specify driver path
from selenium import webdriver

driver = webdriver.Chrome(
    executable_path="/path/to/chromedriver"
)

The New Way (Automatic!)

Now Selenium Manager handles everything. Just write:

from selenium import webdriver

driver = webdriver.Chrome()  # That's it!

Environment Setup

What You Need

Think of building with LEGO. You need:

  1. The base plate → Python (or Java, etc.)
  2. The LEGO pieces → Selenium library
  3. The instruction book → Your test code

Step-by-Step Setup

Step 1: Install Python

Download from python.org and install it.

Check if it works:

python --version

Step 2: Install Selenium

pip install selenium

Step 3: Write Your First Test

from selenium import webdriver

# Start browser
driver = webdriver.Chrome()

# Go to website
driver.get("https://google.com")

# Print the title
print(driver.title)

# Close browser
driver.quit()

Quick Environment Checklist

Component Check Command Expected
Python python --version 3.8+
Pip pip --version Any version
Selenium pip show selenium 4.0+
Browser Open Chrome/Firefox Latest
graph TD A[Install Python] --> B[Install Selenium] B --> C[Write Test Code] C --> D[Run Test] D --> E[Browser Opens Automatically]

Selenium Manager

Your Automatic Helper

Remember how we said you used to manually download browser drivers? Selenium Manager fixes this forever!

What It Does

Selenium Manager is like a smart assistant that:

  1. 🔍 Detects your browser version
  2. 📥 Downloads the matching driver
  3. đź“‚ Stores it in the right place
  4. 🔄 Updates when needed

How It Works

graph TD A[You run: driver = webdriver.Chrome] --> B[Selenium Manager activates] B --> C{Driver exists?} C -->|No| D[Check Chrome version] D --> E[Download matching ChromeDriver] E --> F[Cache driver locally] F --> G[Start browser] C -->|Yes| G

Before vs After

Before Selenium Manager After Selenium Manager
Manual driver downloads Automatic downloads
Version mismatch errors Always matches
PATH configuration No config needed
Frequent breakage Just works

Example: Zero Configuration

from selenium import webdriver

# Selenium Manager handles everything!
driver = webdriver.Chrome()
driver.get("https://example.com")
driver.quit()

No paths. No downloads. No headaches.

Where Drivers Are Stored

Selenium Manager caches drivers in:

  • Windows: ~/.cache/selenium/
  • Mac/Linux: ~/.cache/selenium/

You never need to touch these files!


Putting It All Together

The Complete Picture

graph TD A[Your Python Script] --> B[Selenium Library] B --> C[Selenium Manager] C --> D[Downloads ChromeDriver] D --> E[ChromeDriver Executable] E --> F[Chrome Browser] F --> G[Website You're Testing]

Your First Complete Test

from selenium import webdriver
from selenium.webdriver.common.by import By

# 1. Start browser (Selenium Manager
#    handles driver automatically)
driver = webdriver.Chrome()

# 2. Go to a website
driver.get("https://google.com")

# 3. Find the search box
search = driver.find_element(
    By.NAME, "q"
)

# 4. Type something
search.send_keys("Selenium")

# 5. Submit the search
search.submit()

# 6. Print page title
print(driver.title)

# 7. Close everything
driver.quit()

Key Takeaways

Concept Remember This
Selenium Robot that controls browsers
WebDriver Messenger between code and browser
Browser Driver Translator for each browser
Environment Python + Selenium library
Selenium Manager Auto-downloads drivers

The Magic Formula

Your Code + Selenium + Browser = Automated Testing

You’re now ready to automate the web! 🎉


What’s Next?

Now that you understand the basics:

  1. Write simple automation scripts
  2. Learn to find elements on pages
  3. Handle clicks, typing, and navigation
  4. Build complete test suites

Remember: Selenium is your robot helper. You give the instructions, it does the work. No more clicking the same buttons 1000 times!

Loading story...

No Story Available

This concept doesn't have a story yet.

Story Preview

Story - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

Interactive Preview

Interactive - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

No Interactive Content

This concept doesn't have interactive content yet.

Cheatsheet Preview

Cheatsheet - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

No Cheatsheet Available

This concept doesn't have a cheatsheet yet.

Quiz Preview

Quiz - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

No Quiz Available

This concept doesn't have a quiz yet.