It is important to note that Selenium RC (Remote Control) is a deprecated and obsolete technology. It was replaced by Selenium WebDriver (introduced in Selenium 2.0) over a decade ago. The official Selenium project no longer supports RC.
If you are maintaining a very old legacy system, you might be looking for RC, but if you are starting a new project or learning automation, you must use Selenium WebDriver.
Here is the information for both scenarios:
The Modern Way (Selenium WebDriver)
This is the standard for Python automation today. It communicates directly with the browser rather than injecting JavaScript (which is how RC worked).
Prerequisites:
pip install selenium
Example Script:
from selenium import webdriver
from selenium.webdriver.common.by import By
# Initialize the browser (Chrome in this example)
# Note: You may need 'chromedriver' installed on your path
driver = webdriver.Chrome()
# Navigate to a website
driver.get("http://www.google.com")
# Find an element and interact with it
search_box = driver.find_element(By.NAME, "q")
search_box.send_keys("Selenium Python")
search_box.submit()
# Print the page title
print(driver.title)
# Close the browser
driver.quit()
The Legacy Way (Selenium RC)
If you are absolutely forced to run old Selenium RC code, you will face significant hurdles:
- You need Python 2.7 (Selenium RC libraries are generally not compatible with Python 3+).
- You need the
seleniumlibrary version x (e.g.,pip install selenium==1.2.4). - You must manually start the Selenium Server (a
.jarfile) before running your script.
The Legacy Workflow:
- Start the server:
java -jar selenium-server-standalone-<version>.jar - Run the Python script.
Example Legacy Code (Python 2.7 style):
# This code is OBSOLETE and will not work on modern Python environments
import selenium
# Connect to the RC server running on localhost port 4444
sel = selenium.selenium("localhost", 4444, "*chrome", "http://www.google.com")
sel.start()
sel.open("/")
sel.type("q", "Selenium RC code")
sel.click("btnG")
sel.wait_for_page_to_load(5000)
print(sel.get_title())
sel.stop()
Why you should migrate to WebDriver
If you have existing RC code (often called "Selenese"), you should plan to migrate to WebDriver immediately because:
- Speed: WebDriver is significantly faster.
- Reliability: RC relied on JavaScript injection, which modern browsers often block or handle differently due to security policies.
- Support: There is no community support for RC anymore.
Migration Tip:
There used to be a tool called webdriver-backed-selenium that allowed you to use the RC API while running WebDriver under the hood, but even that is removed from modern Selenium libraries. The only path forward is to rewrite your scripts using the WebDriver API (shown in section 1).
