To write your first Selenium script, install a Selenium language binding, open a browser with WebDriver, navigate to a practice page, interact with its form, verify the result, and close the session. This guide uses Python for a complete local example. Selenium Manager handles many driver setup tasks automatically, so downloading a driver by hand is not the default first step.
1. Choose a Selenium learning path
Selenium is a browser automation project. Its WebDriver interface lets code control a browser through a browser-specific driver, and WebDriver is a W3C Recommendation. Selenium’s official documentation describes it this way: “WebDriver drives a browser natively; learn more about it.”
There are two useful starting points: Selenium IDE, a record-and-playback extension, and WebDriver, the code-based approach used in the tutorials below. IDE can introduce browser actions with less coding; WebDriver is the right path if you want to write scripts and tests.
| Path | Coding depth | Where it runs | Setup burden |
|---|---|---|---|
| Selenium IDE | Lower; record and play back browser actions | In a browser extension | Install the extension |
| WebDriver locally | Write code that controls a browser | Your computer | Install a language binding and browser; Selenium Manager can manage drivers in supported setups |
| Selenium Grid or hosted browser service | Write WebDriver tests, then run them remotely | Across machines or a cloud service | Additional configuration; unnecessary for a first local script |
2. Install Selenium and prepare a browser
This tutorial uses Python 3 and Chrome. Install Python and a supported browser first. Then create a project directory and install Selenium with Python’s package installer:
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
python -m venv .venv
# macOS or Linux
source .venv/bin/activate
# Windows PowerShell
.venvScriptsActivate.ps1
python -m pip install selenium
The activation command differs by operating system; use the command for your shell. Selenium’s getting-started guide treats the language binding and browser as the setup components. Current Selenium releases include Selenium Manager, which can manage a missing driver automatically in supported setups. You do not need to make manual driver installation your first hurdle. If automatic management cannot obtain or use a driver in your environment, consult the official Selenium Manager documentation and getting-started guide for current requirements and manual alternatives.
3. Start and reliably close a WebDriver session
Create a file named first_selenium_test.py. The webdriver.Chrome() call starts a browser session. The try/finally pattern ensures that quit() runs even if navigation or an assertion fails.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
4. Navigate to a practice page and inspect it
The official first-script example uses Selenium’s stable sample form at https://www.selenium.dev/selenium/web/web-form.html. The script reads the page title after navigation, which gives an immediate check that the page opened.
5. Find elements, enter text, and submit
The sample form has a text field located by its my-text name and a submit button found with a CSS selector. Locators identify page elements; Selenium then sends text to the field and clicks the button.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
6. Wait for and verify the result
After submitting, the script waits for the result message to become visible and checks its text. An explicit wait is more reliable than pausing for a fixed number of seconds: it proceeds as soon as the expected condition is met, while still failing after a bounded timeout if the page does not respond as expected.
7. Put the complete first script together
Save this runnable example in first_selenium_test.py and run it from the activated environment with python first_selenium_test.py.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
URL = "https://www.selenium.dev/selenium/web/web-form.html"
# Starts Chrome; Selenium Manager can manage the driver in supported setups.
driver = webdriver.Chrome()
try:
driver.get(URL)
print("Page title:", driver.title)
text_field = driver.find_element(By.NAME, "my-text")
text_field.send_keys("Selenium beginner")
driver.find_element(By.CSS_SELECTOR, "button").click()
result = WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.ID, "message"))
)
assert result.text == "Received!", f"Unexpected result: {result.text!r}"
print("PASS: the form returned", result.text)
finally:
driver.quit()
The expected page title is Web form, and the sample form’s success message is Received!. The assertion turns the script into a basic test: it fails visibly if the form does not produce the expected outcome.
8. Troubleshoot common first-run failures
- Python cannot import Selenium: the package may have been installed into a different Python environment. Activate the project environment and run
python -m pip install seleniumusing the samepythoncommand you use to launch the script. - Chrome does not start or a driver error appears: confirm Chrome is installed and available to your user. Selenium Manager can manage drivers in supported configurations, but network restrictions, browser support, or environment-specific settings may prevent automatic setup. Check Selenium’s current Manager documentation before choosing a manual driver setup.
- The script times out waiting for the message: check that the sample page loaded, the submit button was clicked, and the locators still match the page. A timeout is preferable to silently accepting a missing result; investigate the page state rather than simply increasing the wait without limit.
- An element cannot be found: verify the page URL and locator. The example relies on the sample page’s
my-textfield, a button, and an element with IDmessage. - The browser remains open after an error: keep browser work inside the
tryblock and calldriver.quit()infinally, as shown. This ends the session when the test succeeds or raises an exception.
9. Know when to add a test runner or remote execution
The script above is a single local check, useful for learning the WebDriver sequence. When a project needs repeatable tests, use a test runner suited to your language and project; there is no one runner that fits every Selenium binding. Organize related tests and assertions in that runner rather than turning a beginner script into a large framework prematurely.
Recommended Free Tools
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Selenium Grid is a next step when you need to distribute execution across machines and browsers. A hosted service is another optional route to remote browser execution; Sauce Labs documents a Selenium cloud quickstart. Neither Grid nor a cloud account is required to complete the local tutorial. See the official Selenium Grid documentation and Sauce Labs Selenium quickstart for their respective approaches.
Or skip the browser setup
If you need a screenshot rather than an interactive WebDriver test, ScreenshotNeo is a website screenshot API and MCP server. One GET request returns an image or PDF; it is not a replacement for Selenium tests that must enter data and verify behavior. For a quick image capture, the API call is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for the access key and request options. It removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed. Its MCP server lets AI agents use screenshot tools, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free and get 1,000 screenshots a month with no card.
Frequently Asked Questions
Do I need to download a browser driver before writing my first Selenium script?
Usually not: Selenium Manager, included with current Selenium releases, can manage a missing driver in supported setups. Manual setup is an option if your environment requires it.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Can I use Selenium without writing code?
Selenium IDE offers record-and-playback as a lower-code introduction. WebDriver is the code-based path demonstrated here.
Is Selenium Grid required to run this tutorial?
No. The sample runs locally; Grid is for scaling execution across machines and browsers.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

