PYTHON+SELENIUM2 Build automation test environment __python

Source: Internet
Author: User
Tags openssl openldap

Many of the rice technology projects have used the crawler to collect Web data, breakthroughs in the anti-reptile, automated testing, regression testing also requires the meter to consider building automation, to improve the entire team's ultimate efficiency.

Due to busy requirements and product process specifications, there is now a lot of research on testing technology. But whatever you do, it's important to do it.

Automation is mainly due to team building considerations, on the one hand, in order to provide testing the efficiency of the Department to ensure product quality, on the other hand, but also to enhance the team members of the testing skills, to ensure the healthy development of teams. But no matter what, automation must be done, otherwise the tedious regression testing is without any efficiency assurance and quality assurance.

The initial plan is to use Python as a scripting language,Selenium as a web -side test tool, currently built primarily on the web side.

Rice Blog Original: python+selenium2 to build an automated test environment

Python Installation

Yum-y Update

Yum-y install gcc gcc-g++ python python-devel python-pip

Yum-y Install Xvfb Firefox

Pip Install Pyvirtualdisplay

Yum-y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-deve L zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl curl-devel e2fsprogs E2 Fsprogs-devel krb5 krb5-devel libidn libidn-devel OpenSSL openssl-devel openldap openldap-devel Nss_ldap Openldap-clients Openldap-servers Unzip Subversion

PyPI Official website: https://pypi.python.org/pypi

PIP Official website: https://pypi.python.org/pypi/pip/

BS4 Official website: https://pypi.python.org/pypi/beautifulsoup4/

Setuptools Official website: https://pypi.python.org/pypi/setuptools/

Selenium official website: https://pypi.python.org/pypi/selenium

Tornado official Website: Https://pypi.python.org/pypi/tornado

Tornado official Website: http://www.tornadoweb.org

Tornado github:https://github.com/tornadoweb/tornado/

Pyvirtualdisplay Official website: https://pypi.python.org/pypi/PyVirtualDisplay (including XVFB)

Pyvirtualdisplay Github:https://github.com/ponty/pyvirtualdisplay

Firefox old version download: http://ftp.mozilla.org/pub/firefox/releases/(recommended)

This section mainly records the process of simply building a python+selenium test environment, as follows:

Basic Environment: Windows 7 64bit

1, build the python development environment , the version is the current latest version python2.7.5

Choose to download the latest Windows Installer from the Python official website: python-2.7.5.amd64.msi,

Note that the 64bit is selected here. After installation, you need to add C:\Python27 to the system's environment variable path, and then you can go to the command line.

2, Setuptools and Pip tool installation

Both tools are part of Python's Third-party toolkit software, somewhat similar to Linux's installation package software, but the PIP is more powerful than the Setuptools feature.

Setuptools official explanation: Download, build, install, upgrade, and uninstall Python packages-easily!

On the official Python website, you can find Setuptools downloads, where Windows offers only 32bit downloads, Setuptools-0.6c11.win32-py2.7.exe, and direct double-click to install.

PIP Official Explanation: A tool for installing and managing Python packages.

CMD enter command line: Easy_install PIP can be installed online.

Note: You should be aware that when you install Setuptools, you can see the script directory under the Python installation directory, as shown in the following illustration:

After this catalog is generated, you need to add path:c:\python27\scripts to the system environment variable before you can install PIP online using the Easy_install command.

3. Installation Selenium

Selenium Official Download: https://pypi.python.org/pypi/selenium#downloads

Selenium Latest Version: Selenium-2.53.4.tar.gz

Because of the need to combine Python and selenium, of course selenium also provides a python based implementation, so the selenium package needs to be installed in the Python library to facilitate the invocation of Python development.

After CMD enters the command line: Pip install selenium executes, automates the search for the latest selenium version to download and install, as shown in the following illustration:

The above display indicates that the online installation selenium successful.

4, Python + Selenium sample

Here you can write the following program directly in the Python editor and save the hello_selenium.py

1 2 3 4 5 6 7 8 From selenium import webdriver driver = Webdriver. Firefox () driver.get (' https://blog.mimvp.com ') assert "blog.mimvp.com blog". Decode (' Utf-8 ') in Driver.title prin T Driver.title Driver.close ()

Run F5 in the Python editor to see if the Firefox browser is successfully invoked ...

Above a foundation of the Python+selenium Automation environment has been built to complete.

Selenium Multi-browser implementation

After building the PYTHON+SELENIUM2 automated test environment, you will need to test whether the selenium version of Python supports running on different browsers, and currently we are on the three most common browsers (Ie,chrome, FireFox) through the script test.

1) IE browser

Run the test script on IE browser, first need to download IEDriverServer.exe, put in IE browser installation directory and the same level directory, the script is as follows:

1 2 3 4
Related Article

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.