Selenium (software)

Last updated

Selenium
Initial release2004;20 years ago (2004)
Stable release
4.16.0 [1]   OOjs UI icon edit-ltr-progressive.svg / 6 December 2023;2 months ago (6 December 2023)
Repository
Written inSelenium Server: Java; Selenium WebDriver (works without Selenium Server), official support: JavaScript (Node.js), Python, Ruby, Java or C# [2]
Operating system Cross-platform
Type Software testing framework for web applications
License Apache License 2.0
Website selenium.dev   OOjs UI icon edit-ltr-progressive.svg

Selenium is an open source umbrella project for a range of tools and libraries aimed at supporting browser automation. [3] It provides a playback tool for authoring functional tests across most modern web browsers, without the need to learn a test scripting language (Selenium IDE). [4] It also provides a test domain-specific language (Selenese) to write tests in a number of popular programming languages, including JavaScript (Node.js), C#, Groovy, Java, Perl, PHP, Python, Ruby and Scala. Selenium runs on Windows, Linux, and macOS. It is open-source software released under the Apache License 2.0.

Contents

Selenium is an open-source automation framework for web applications, enabling testers and developers to automate browser interactions and perform functional testing. With versatile tools like WebDriver, Selenium supports various programming languages and facilitates cross-browser testing, making it a go-to choice for efficient and scalable web automation.

History

Selenium was originally developed by Jason Huggins in 2004 as an internal tool at ThoughtWorks. [5] Huggins was later joined by other programmers and testers at ThoughtWorks, before Paul Hammant joined the team and steered the development of the second mode of operation that would later become "Selenium Remote Control" (RC). The tool was open sourced that year.

In 2005 Dan Fabulich and Nelson Sproul (with help from Pat Lightbody) made an offer to accept a series of patches that would transform Selenium-RC into what it became best known for. In the same meeting, the steering of Selenium as a project would continue as a committee, with Huggins and Hammant being the ThoughtWorks representatives. [6]

In 2007, Huggins joined Google. Together with others like Jennifer Bevan, he continued with the development and stabilization of Selenium RC. At the same time, Simon Stewart at ThoughtWorks developed a superior browser automation tool called WebDriver. In 2009, after a meeting between the developers at the Google Test Automation Conference, it was decided to merge the two projects, and call the new project Selenium WebDriver, or Selenium 2.0. [7]

In 2008, Philippe Hanrigou (then at ThoughtWorks) made "Selenium Grid", which provides a hub allowing the running of multiple Selenium tests concurrently on any number of local or remote systems, thus minimizing test execution time. Grid offered, as open source, a similar capability to the internal/private Google cloud for Selenium RC. Pat Lightbody had already made a private cloud for "HostedQA" which he went on to sell to Gomez, Inc.

The name Selenium comes from a joke made by Huggins in an email, mocking a competitor named Mercury, saying that you can cure mercury poisoning by taking selenium supplements. The others that received the email took the name and ran with it. [8]

Components

Selenium is composed of several components with each taking on a specific role in aiding the development of web application test automation. [9]

Selenium IDE

Selenium IDE is a complete integrated development environment (IDE) for Selenium tests. It is implemented as a Firefox Add-On and as a Chrome Extension. It allows for recording, editing and debugging of functional tests. It was previously known as Selenium Recorder. Selenium-IDE was originally created by Shinya Kasatani and donated to the Selenium project in 2006. Selenium IDE began being actively maintained in 2018. [10] [11] [12] [13]

Scripts may be automatically recorded and edited manually providing autocompletion support and the ability to move commands around quickly. Scripts are recorded in Selenese, a special test scripting language for Selenium. Selenese provides commands for performing actions in a browser (click a link, select an option) and for retrieving data from the resulting pages. Selenese serves as the language for composing Selenium Commands, which are utilized in the testing of web applications. These commands, tailored to the HTML tags of UI elements, facilitate the verification of their existence. They guide Selenium in comprehending the specific actions or operations to execute.

Selenium client API

As an alternative to writing tests in Selenese, tests can also be written in various programming languages. These tests then communicate with Selenium by calling methods in the Selenium Client API. Selenium currently provides client APIs for Java, C#, Ruby, JavaScript, R and Python.

Selenium Remote Control

Selenium Remote Control (RC) is a server, written in Java, that accepts commands for the browser via HTTP. RC makes it possible to write automated tests for a web application in any programming language, which allows for better integration of Selenium in existing unit test frameworks. To make writing tests easier, Selenium project currently provides client drivers for PHP, Python, Ruby, .NET, Perl and Java. The Java driver can also be used with JavaScript (via the Rhino engine). An instance of selenium RC server is needed to launch html test case - which means that the port should be different for each parallel run.[ citation needed ] However, for Java/PHP test case only one Selenium RC instance needs to be running continuously. [14]

Selenium Remote Control was a refactoring of Driven Selenium or Selenium B designed by Paul Hammant, credited with Jason as co-creator of Selenium. The original version directly launched a process for the browser in question, from the test language of Java, .NET, Python or Ruby. The wire protocol (called 'Selenese' in its day) was reimplemented in each language port. After the refactor by Dan Fabulich and Nelson Sproul (with help from Pat Lightbody) there was an intermediate daemon process between the driving test script and the browser. The benefits included the ability to drive remote browsers and the reduced need to port every line of code to an increasingly growing set of languages. Selenium Remote Control completely took over from the Driven Selenium code-line in 2006. The browser pattern for 'Driven'/'B' and 'RC' was response/request, which subsequently became known as Comet.

Selenium RC served as the flagship testing framework of the entire project of selenium for a long-standing time. And significantly[ editorializing ] Selenium RC is the first and foremost automated web testing tool that enabled users to adopt their preferred programming language. [15] [16]

With the release of Selenium 2, Selenium RC has been officially deprecated in favor of Selenium WebDriver.

Selenium WebDriver

At the core of Selenium is Selenium WebDriver, an interface to write instructions that work interchangeably across browsers. It is the successor to Selenium RC. Selenium WebDriver accepts commands (sent in Selenese, or via a Client API) and sends them to a browser. This is implemented through a browser-specific browser driver, which sends commands to a browser and retrieves results. Most browser drivers actually launch and access a browser application (such as Firefox, Google Chrome, Internet Explorer, Safari, or Microsoft Edge); there is also an HtmlUnit browser driver, which simulates a browser using the headless browser HtmlUnit.

Unlike in Selenium 1, where the Selenium server was necessary to run tests, Selenium WebDriver does not need a special server to execute tests. Instead, the WebDriver directly starts a browser instance and controls it. However, Selenium Grid can be used with WebDriver to execute tests on remote systems (see below). Where possible, WebDriver uses native operating system level functionality rather than browser-based JavaScript commands to drive the browser. This bypasses problems with subtle differences between native and JavaScript commands, including security restrictions. [17]

As of early 2012, Simon Stewart (inventor of WebDriver), who was then with Google, and David Burns of Mozilla were negotiating with the W3C to make WebDriver an Internet standard. In July 2012, the working draft was released and the recommendation followed in June 2018. [18] Selenium WebDriver (Selenium 2.0) is fully implemented and supported in JavaScript (Node.js), Python, Ruby, Java, Kotlin, and C#. As of 2021, Selenium 4 is a release candidate. [19]

Examples

Below are some of the simplest instructions one can make:

Python
fromseleniumimportwebdriverfromselenium.webdriver.common.byimportByfromselenium.webdriver.common.keysimportKeysfromselenium.webdriver.support.uiimportWebDriverWaitfromselenium.webdriver.support.expected_conditionsimportpresence_of_element_located#This example requires Selenium WebDriver 3.13 or newerwithwebdriver.Firefox()asdriver:wait=WebDriverWait(driver,10)driver.get("https://google.com/ncr")driver.find_element(By.NAME,"q").send_keys("cheese"+Keys.RETURN)first_result=wait.until(presence_of_element_located((By.CSS_SELECTOR,"h3")))print(first_result.get_attribute("textContent"))
Java
importorg.openqa.selenium.By;importorg.openqa.selenium.Keys;importorg.openqa.selenium.WebDriver;importorg.openqa.selenium.WebElement;importorg.openqa.selenium.firefox.FirefoxDriver;importorg.openqa.selenium.support.ui.WebDriverWait;import staticorg.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated;importjava.time.Duration;publicclassHelloSelenium{publicstaticvoidmain(String[]args){WebDriverdriver=newFirefoxDriver();WebDriverWaitwait=newWebDriverWait(driver,Duration.ofSeconds(10));try{driver.get("https://google.com/ncr");driver.findElement(By.name("q")).sendKeys("cheese"+Keys.ENTER);WebElementfirstResult=wait.until(presenceOfElementLocated(By.cssSelector("h3")));System.out.println(firstResult.getAttribute("textContent"));}finally{driver.quit();}}}
C#
usingSystem;usingOpenQA.Selenium;usingOpenQA.Selenium.Firefox;usingOpenQA.Selenium.Support.UI;classHelloSelenium{staticvoidMain(){using(IWebDriverdriver=newFirefoxDriver()){WebDriverWaitwait=newWebDriverWait(driver,TimeSpan.FromSeconds(10));driver.Navigate().GoToUrl("https://www.google.com/ncr");driver.FindElement(By.Name("q")).SendKeys("cheese"+Keys.Enter);wait.Until(webDriver=>webDriver.FindElement(By.CssSelector("h3")).Displayed);IWebElementfirstResult=driver.FindElement(By.CssSelector("h3"));Console.WriteLine(firstResult.GetAttribute("textContent"));}}}

Selenium Grid

Selenium Grid is a server that allows tests to use web browser instances running on remote machines. With Selenium Grid, one server acts as the central hub. Tests contact the hub to obtain access to browser instances. The hub has a list of servers that provide access to browser instances (WebDriver nodes), and lets tests use these instances. Selenium Grid allows running tests in parallel on multiple machines and to manage different browser versions and browser configurations centrally (instead of in each individual test).

The ability to run tests on remote browser instances is useful to spread the load of testing across several machines and to run tests in browsers running on different platforms or operating systems. The latter is particularly useful in cases where not all browsers to be used for testing can run on the same platform. [20]

See also

Related Research Articles

In computing, cross-platform software is computer software that is designed to work in several computing platforms. Some cross-platform software requires a separate build for each platform, but some can be directly run on any platform without special preparation, being written in an interpreted language or compiled to portable bytecode for which the interpreters or run-time packages are common or standard components of all supported platforms.

Expect is an extension to the Tcl scripting language written by Don Libes. The program automates interactions with programs that expose a text terminal interface. Expect, originally written in 1990 for the Unix platform, has since become available for Microsoft Windows and other systems.

EGL, originally developed by IBM and now available as the EDT open source project under the Eclipse Public License (EPL), is a programming technology designed to meet the challenges of modern, multi-platform application development by providing a common language and programming model across languages, frameworks, and runtime platforms.

Silk Test is a tool for automated function and regression testing of enterprise applications. It was originally developed by Segue Software which was acquired by Borland in 2006. Borland was acquired by Micro Focus International in 2009 and Micro Focus was later acquired by OpenText in 2023. The original name for the product from 1993 through 1996 was QA Partner.

<span class="mw-page-title-main">Google Web Toolkit</span> Free Java library

Google Web Toolkit, or GWT Web Toolkit, is an open-source set of tools that allows web developers to create and maintain JavaScript front-end applications in Java. It is licensed under Apache License 2.0.

<span class="mw-page-title-main">Aptana</span> Text editor

Aptana, Inc. is a company that makes web application development tools for use with a variety of programming languages. Aptana's main products include Aptana Studio, Aptana Cloud and Aptana Jaxer.

<span class="mw-page-title-main">Watir</span>

Watir, is an open-source family of Ruby libraries for automating web browsers. It drives Internet Explorer, Firefox, Chrome, Opera and Safari, and is available as a RubyGems gem. Watir was primarily developed by Bret Pettichord and Paul Rogers.

QF-Test from Quality First Software is a cross-platform software tool for automated testing of programs via the graphical user interface. The program is specialized on cross-browser test automation of static and dynamic web-based applications. Version 4.1 added support for MacOS and the Apple Safari and Microsoft Edge browsers via the Selenium WebDriver. RESTful web service testing. From version 5.0, Windows applications can also be tested and modern C++ applications. Version 5.3 added support for the Chrome DevTools protocol, which allows browsers to be controlled using CDP drivers.

iMacros Browser-based application for macro recording, editing and playback

iMacros is a browser-based application for macro recording, editing and playback for web automation and testing. It is provided as a standalone application and extension for Mozilla Firefox, Google Chrome, and Internet Explorer web browsers. Developed by iOpus/Ipswitch, It adds record and replay functionality similar to that found in web testing and form filler software. The macros can be combined and controlled via JavaScript. Demo macros and JavaScript code examples are included with the software. Running strictly JavaScript-based macros was removed in later versions of iMacros browser extensions. However, users can use alternative browser like Pale Moon, based on older versions of Mozilla Firefox to use JavaScript files for web-based automated testing with Moon Tester Tool.

<span class="mw-page-title-main">TestComplete</span> Software test automation tool

TestComplete is a functional automated testing platform developed by SmartBear Software. TestComplete gives testers the ability to create automated tests for Microsoft Windows, Web, Android, and iOS applications. Tests can be recorded, scripted or manually created with keyword driven operations and used for automated playback and error logging.

<span class="mw-page-title-main">Robot Framework</span> Type of test automation framework

Robot Framework is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD). It is a keyword-driven testing framework that uses tabular test data syntax.

<span class="mw-page-title-main">Test Studio</span> Software test automation tool

Progress Telerik Test Studio is a Windows-based software test automation tool for web and desktop that supports functional testing, software performance testing, load testing and RESTful API testing developed by Telerik. The tool ships with a plugin for Visual Studio and a standalone app that use the same repositories and file formats. Test Studio supports HTML, AJAX, Silverlight, ASP.NET MVC, JavaScript, WPF, Angular, React, ASP.NET AJAX, ASP.NET Core, and Blazor. Any application that runs on .NET 5, .NET Core, .NET 6 or higher can be automated with Test Studio. Test Studio supports cross-browser testing for Internet Explorer, Firefox, Microsoft Edge, and Chrome.

A headless browser is a web browser without a graphical user interface.

HtmlUnit is a headless web browser written in Java. It allows high-level manipulation of websites from other Java code, including filling and submitting forms and clicking hyperlinks. It also provides access to the structure and the details within received web pages. HtmlUnit emulates parts of browser behaviour including the lower-level aspects of TCP/IP and HTTP. A sequence such as getPage(url), getLinkWith("Click here"), click allows a user to navigate through hypertext and obtain web pages that include HTML, JavaScript, Ajax and cookies. This headless browser can deal with HTTPS security, basic HTTP authentication, automatic page redirection and other HTTP headers. It allows Java test code to examine returned pages either as text, an XML DOM, or as collections of forms, tables, and links.

Capybara is a web-based test automation software that simulates scenarios for user stories and automates web application testing for behavior-driven software development. It is written in the Ruby programming language.

<span class="mw-page-title-main">Katalon Studio</span> Automation testing software tool

Katalon Platform is an automation testing software tool developed by Katalon, Inc. The software is built on top of the open-source automation frameworks Selenium, Appium with a specialized IDE interface for web, API, mobile and desktop application testing. Its initial release for internal use was in January 2015. Its first public release was in September 2016. In 2018, the software acquired 9% of market penetration for UI test automation, according to The State of Testing 2018 Report by SmartBear.

Playwright is an open-source automation library for browser testing and web scraping developed by Microsoft and launched on 31 January 2020, which has since become popular among programmers and web developers.

References

  1. "Release Selenium 4.16". December 6, 2023.
  2. "Downloads". Selenium.
  3. "The Selenium Browser Automation Project". selenium.dev. March 16, 2020. Retrieved November 1, 2021.
  4. Abdullaiev, O.A.; Ibrahimova, L. V. (2020). "Review of testing software: Selenium software" (PDF). Вінницький національний технічний університет. УДК 004.457.
  5. "About Selenium".
  6. "Selenium History". www.selenium.dev. Retrieved August 11, 2021.
  7. "The Selenium Project". thenewcircle.com. NewCircle. Retrieved June 29, 2014.
  8. Krill, Paul (April 6, 2011). "Open source Selenium web app test suite to support iPhone and Android". InfoWorld. Archived from the original on May 5, 2011. Retrieved May 9, 2012. Selenium was so named because Huggins, dissatisfied with testing tools on the market, was seeking a name that would position the product as an alternative to Mercury Interactive QuickTest Professional commercial testing software. The name, Selenium, was selected because selenium mineral supplements serve as a cure for mercury poisoning, Huggins explained.
  9. Moizuddin, Khaja (June 7, 2018). "Components of the Selenium Automation Tool". dzone.com. DevOps Zone. Retrieved July 10, 2019.
  10. "It's back! Selenium IDE Reborn with Dave Haeffner". testingpodcast.com. December 24, 2018.
  11. Dave, Tour de (August 6, 2018). "Selenium IDE Is Dead, Long Live Selenium IDE!". Selenium IDE Official Blog. Retrieved November 27, 2019 via seleniumhq.wordpress.com.
  12. Colantonio, Joe (November 27, 2018). "Stunning return of Selenium IDE". testguild.com. Retrieved November 27, 2019.
  13. Sargent, Al (March 19, 2019). "List of new Selenium IDE features". applitools.com. Retrieved October 18, 2021.
  14. "Selenium Remote-Control". seleniumhq.org. Retrieved November 13, 2019.
  15. "Selenium 1 (Selenium RC) :: Documentation for Selenium". www.selenium.dev. Retrieved December 20, 2020.
  16. sparkdatabox_author (October 16, 2019). "Selenium | Spark Databox" . Retrieved December 20, 2020.{{cite web}}: |last= has generic name (help)
  17. "The Architecture of Open Source Applications: Selenium WebDriver". aosabook.org. Retrieved February 7, 2016.
  18. Smith, Michael (June 5, 2018). "WebDriver motors on to W3C Recommendation". W3C Blog. Retrieved September 10, 2018.
  19. "Downloads". selenium.dev. Retrieved September 29, 2021.
  20. "Selenium Grid". The Selenium Browser Automation Project. Retrieved September 9, 2020.