Selenium introduction (1)-General Introduction

Source: Internet
Author: User
Tags selenium grid

Author: torrent


Selenium has been adopted by more and more companies as a lightweight Web automated testing framework, but there are almost no Chinese documents about selenium. Therefore, to make it easier for you to use selenium, special selenium document series, including:
I. General Introduction
2. Simple Applications based on core/ide
Iii. Simple RC-based application
Iv. Automatic implementation scheme of selenium core Mode
V. Selenium FAQs

Complete selenium explanation (1)

-- General Introduction

Read suggestion: This section mainly introduces the framework, mode, and principle of Selenium. If you only want to be an application of selenium, this article is a simple introduction, but you can focus on the future. If you want to go deeper and expand selenium, read this article in detail.

Selenium is an open-source project developed and maintained by thoughtworks staff in their spare time and is widely used in thoughtworks projects. Simply put, selenium is an automated Web application function testing tool.
Let's gossip about selenium. what's interesting about selenium is its name: Before selenium appeared, it was the most famous web application function testing tool mercury quanlity center, but it was a commercial tool, powerful functions are expensive, and developers often love and hate them. Therefore, thoughtworker, WHO develops open-source functional testing tools by themselves, calls this tool selenium -- "Mercury", which means "Mercury" and "Selenium" (selenium) it happens to be a special medicine used to exclusively resolve mercury poisoning.
The main feature of selenium is its open source, cross-platform, and many programming languages. You can use HTML to write test cases, you can also use python, Java, PHP, or even Linux Shell to write test cases. With so many features, selenium has become the preferred automated testing tool for more and more QA web application functional testing in recent years. Before accessing specific applications, let's take a look at the framework and principles of Selenium:
Selenium is divided into two parts: core and RC (Remote Control). Among them, core is the basic module that directly writes test code in HTML table, remote control supports writing test cases in Java and other languages. Recently, selenium has released a new remote grid that supports multi-task concurrency and can be viewed as a set of multiple RC instances. Selenium also provides a script recorder selenium-ide, which is a Firefox-based plug-in. In the core mode and RC mode, Java Script is used to control page elements. It provides a wide range of methods to specify HTML page elements and operate on page elements.
Its framework is as follows:


Selenium Core/selenium ide

Selenium core is the core part of Selenium. It consists of some pure js code that can run on different browsers of Windows/Linux, while IDE is an application based on core, use the UI to implement the script recording and playback function similar to qtp/winner.

I. Core operating modes:


1. Run selenium ide
Use the IDE plug-in to load the Core Engine and run the test script. It is mainly used for script recording debugging. It is similar to debugging by development tools and should not be used for testing.
2. deployed on the tested object server and run in http mode
Deploy the Core Engine and test code on the Web server of the tested object and run it as an HTTP request.
3. Local Mode HTA and chrome
The HTA mode is run in IE and chrome is run in Firefox. These two principles use the localization mode of the browser to call the main HTML file-test runner to load the Core Engine library and execute the test cases in test suite.

Ii. Some core JS engine files of selenium core:

Selenium-api.js: Master api library for selenium
Selenium-browserbot.js: The main function library of selenium, the specific methods of the command are in this library.
Selenium-browserdetect.js: browser version check Library
Selenium-logging.js: logging logstore
User-extensions.js: the files used to extend selenium; the functions and extended commands written by the user should all be placed in this file. Of course, you can also put it elsewhere.
Xmlextras. JS: a third-party JavaScript library. It is mainly used for DHTML and XML parsing.

Iii. Selenium ide description:

Selenium IDE is a recording tool that monitors user operations on HTML pages and monitors user operations on HTML pages. Selenium IDE can generate scripts in seven languages: HTML, Java, C #, Ruby, Python, Perl, and PHP.
You can directly open selenium IDE in Firefox and execute HTML scripts.
If you want to execute selenium scripts in other language formats, you need to use the selenium server in RC mode. The use of the six languages is the same.

Selenium RC

In selenium RC mode, the client sends commands to selenium server over the network using various programming languages. After selenium server receives the test commands, start the browser and send a javascript call to it to fully track the HTML page, and return the execution result to the caller through the network.
The principle of selenium server is to embed your Javascript file into a webpage when you open your browser. Then, the selenium webpage is embedded into the target Webpage Through frame. In this way, you can use the JavaScript Object of selenium to control the target webpage.
The selenium client is generally implemented using unit test technology. It determines whether the program runs correctly by judging whether the returned results are consistent with the expected ones.
For example:


Selenium Grid

Selenium grid is a solution based on selenium RC to solve the problem that the RC mode cannot be called concurrently. It can meet the needs of multiple environments and test at the same time. The principle is as follows:
The client uses various programming languages and concurrency methods to send commands to selenium grid over the network. After selenium grid receives the test commands, it starts multiple selenium servers based on different concurrent commands. Then, the grid sends the command to the corresponding server. Each server has the same processing principle as RC.
From the above principle, we can see that grid only provides the environment for running scripts, and cannot determine the form of running scripts (in parallel or multi-Environment mode ). The form of running the script is determined by the configuration of the script itself and the runner of the script (generally JUnit or testng.
The differences between Selenium grid, selenium RC, and selenium Core/IDE are as follows:

Several Concepts 

Action and assertion)
Action: simulates the interaction between a user and a web application. For example, clicking a button and entering a form are common user operations. You can use the selenium command to automate these operations.
Assertion: The assertion verifies the expected results of a command. Common assertions include verifying that the page content or current location is correct. You can find a complete list of available commands on the selenium website. Using the selenium command, the script writer can describe the operations performed by browser BOT in the browser.
Test Suite and test case:
Test Suite: a set of tests. In practice, a module usually corresponds to a test suite, which is displayed in the upper left corner of seleium.
Test Case: A test case that contains multiple actions or assertions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.