What is Selenium?
Selenium is an automation tool widely used to perform browser automation. For example, consider we are working for Amazon and our task is to make sure the user is able to place an order successfully. Say this has to be done every day to make sure there is no breakage in the application due to everyday code deployment. Its tedious and time taking to verify this function manually every day. So here comes our Selenium tool using which we can place an order on Amazon and verify the order goes through, without any manual intervention. Once the test execution is done, we get to see the report if all the tests we coded are passed. This way one can avoid manual testing and any redundant tasks.
Selenium Titbits
- Development: Selenium was developed in the year 2004 by a team in ThoughtWorks.
- Original Name: It was initially called JavascriptTestRunner and was used to automate ThoughtWorks internal application ‘Time and Expenses’.
- How Selenium got its name?: In 2004, the dominant commercial testing tool was made by a company called Mercury Interactive (later acquired by HP). While brainstorming a name for his new project, creator Jason Huggins joked in an email that "mercury poisoning can be cured by taking selenium supplements." The team loved it and the name stuck.
- It is a W3C Standard: Selenium WebDriver became a World Wide Web Consortium (W3C) Recommendation in 2018. This is a massive deal because it means that browser vendors (like Google, Apple, and Microsoft) are now responsible for developing the drivers that allow Selenium to communicate with their browsers. This makes the automation much more stable and "native" than it used to be.
- The "Remote Control" Hack: In the early days, browsers had a security feature called the Same-Origin Policy, which blocked JavaScript from interacting with a site if the script didn't come from that exact same domain. To "trick" the browser, Paul Hammant created Selenium RC (Remote Control). It acted as a HTTP proxy, making the browser believe that the Selenium Core (JavaScript) and the website being tested were from the same source. It was a clever, slightly messy workaround that paved the way for modern automation.
- Google’s Massive Role: While it started at ThoughtWorks, Selenium’s "teenage years" were spent at Google. Jason Huggins joined Google in 2007, and for a long time, Google was the primary driver of the project. They needed a way to test their massive applications (like Gmail and Maps) across every possible browser, so they poured resources into making Selenium scalable.
Why do we use Selenium for Automation?
- Selenium supports browser automation which helps in automating testing all manual test execution for any sort of web application.
- Selenium is an open source software and has huge developer and community support.
- It supports wide range of programming languages like Java, Javascript, C#, Python, and Ruby.
- A single Selenium script can be executed across different environments. This "write once, run anywhere" capability is vital for Cross-Browser Testing.
- Browsers: Chrome, Firefox, Safari, Edge, and Opera.
- Operating Systems: Windows, macOS, and Linux.
- Support for Parallel Execution: With Selenium Grid, we can run multiple tests simultaneously across different browsers and operating systems.
- It integrates seamlessly with:
- Build Tools: Maven, Gradle, Ant.
- CI/CD Tools: Jenkins, Azure DevOps, GitLab.
- Testing Frameworks: JUnit, TestNG, PyTest.
What is the relevance of Selenium in Automation Testing using Python?
The pairing of Selenium and Python is one of the most popular combinations in the world of Quality Assurance.
- Readability: Python allows testers to write scripts that are easy to understand for everyone on the team as its close to plain English
-
Powerful Library Ecosystem: Python has a large library of "packages" that integrate perfectly with Selenium:
- PyTest: The industry-standard framework for organizing and running tests.
- Pandas: For Data-Driven Testing (reading thousands of test cases from CSV/Excel).
- Behave: For Behavior-Driven Development (BDD), allowing you to write tests in "Given/When/Then" format.
- Since Python is the leading language for AI and Machine Learning, using Selenium with Python makes it much easier to integrate AI models that can "heal" broken tests or analyze UI screenshots for visual bugs.
Top comments (0)