Selenium Introduction and Installation

Source: Internet
Author: User
Tags seleniumhq selenium grid

Selenium Introduction

Selenium is a series of web-based automated testing tools. It provides a series of test functions to support Web automation testing. These functions are very flexible and can be used to locate interface elements in many ways, and compare the expected results with the actual performance of the system.

As a powerful test tool, Selenium has several features:

(1) Multi-browser can be tested, such as IE, Firefox, Safari, Chrome, Android phone browser and so on.

(2) can support multiple languages, such as Java, C #, Python, Ruby, PHP, etc.

(3) Cross-platform, such as Windows, Linux, IOS, Android, etc.

(4) Open source is free.

Selenium Tool Group

The selenium consists of several tools, each of which plays a unique role.

  • Selenium IDE. The Selenium IDE is a primary tool for building scripts. It is a Firefox plugin that has an easy-to-use interface. The Selenium IDE has the recording capability to record what the user is doing and export it as a reusable script that supports multiple programming languages and is then used to perform the test.
  • Selenium 1. Selenium 1 (SELENIUM-RC) is one of Selenium's most important testing tools, and some of its features are not supported even in the new version of Selenium 2. It is able to write test code in multiple languages (Java, JavaScript, Ruby, PHP, Python, Perl, and C #), while supporting testing for almost any browser.
  • Selenium 2. Selenium 2(Webdriver), as the new Selenium tool, represents the direction of future Selenium development. This new set of automated testing tools provides a number of features, including a better organized, object-oriented API, and overcomes the limitations of testing in previous Selenium 1 releases. The code for Selenium 1 can be ported to Selenium 2 with few modifications. At the same time, Selenium 2 also provides a forward-compatible Selenium 1 interface.
  • Selenium Grid. The Selenium grid enables testing of Selenium 1 to run in several different environments, as well as to allow tests to be executed in parallel. In other words, each test can run on a different machine at the same time. This has two benefits. First, if you have a large set of tests or slow tests, you can run the test at the same time and on different machines through the Selenium grid, and second, if the test must run in more than one environment, the Selenium grid has the "same time, Different machine "features are also easy to do this. In any case, the Selenium Grid can significantly improve the efficiency of testing.

This paper mainly introduces Selenium 2 (webdriver).

    • Selenium 2 provides a set of friendly, object-oriented APIs (different from Selenium 1 's method-based API). Selenium 2 is a complete set of class libraries, independent of any test framework, no need to start other processes or install other programs, and do not need to start the service as Selenium 1. In addition, the technical solutions used are different. Selenium 1 is running JavaScript in the browser for testing, while Selenium 2 controls the browser via native browser support or browser extensions. Webdriver supports Firefox (firefoxdriver), IE (Internetexplorerdriver), Opera (Operadriver), and Chrome (chromedriver) browsers.
Selenium 2 (webdriver) installation (Windows environment)

I chose Python as the scripting language, so I need to install Python and the appropriate tools first and then install Selenium 2 (Selenium webdriver).

  1. Install Python. Go to https://www.python.org/downloads/to download the Python installation package and click Install.
  2. install Setuptools. Setuptools is a tool for downloading, installing, upgrading, and uninstalling Python packages. There are several ways to install Setuptools, this article uses: Go to https://pypi.python.org/pypi/setuptools/to download the ez_setup.py file, run the python command under this file path: python ez_setup.py , automatically download the corresponding Python version of the Setuptools, automatically installed.
  3. Install PIP. Go to Https://pypi.python.org/pypi/pip, download pip-6.0.8.tar.gz, unzip. CMD run: Python setup.py install. Then switch to the Python27\scripts directory and run Easy_install PIP. Installation is complete.
  4. Installing Selenium . In the networked state, enter the command directly in the Python27\scripts directory: Pip install-u Selenium. Can.
  5. Download and install the driver for each browser.

complete the above steps, both the Python environment and Selenium 2 have been installed. Here's a simple script to test:

1  from Import Webdriver 2 3 browser = webdriver. Firefox ()4 browser.get ('http://seleniumhq.org/')

Script Execution Process:

    1. Open the Firefox browser;
    2. Open Web page http://seleniumhq.org/;

Each step of the installation process, there are many ways (networking, not networking, etc.). You can also try other options to install it when you install it.

Selenium Introduction and Installation

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: info-contact@alibabacloud.com 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.