Automated testing and selenium detailed principles

I. Introduction Automation

1. What is automation?
Look at the recent career opportunities reference to "software test engineer", are basically requirements for automated testing.

For example:
Learn selenium, appium or other automated testing framework
familiar with at least one object-oriented development language, there is a certain code skills priority
familiar with Java or python, a certain degree of test automation experience and ability to read the code

2, automated interpretation:

Automated testing is to make the software being tested themselves up and running, perform the functions of the software; or other tools is to make yourself up and running, to check the internal and external software.
Let yourself move the machine, it is automatic. Let the machine in accordance with the requirements of humanity, all the functionality of the software to traverse again, this is automation.

3, automated testing

Mainstream of automated testing solutions, without exception, has the man-machine communication programming languages, plus the tools to operate the machine components.
VBScript + QTP (HP UFT), a commercial function automated testing solutions
Python / PHP / Java / C # / JavaScprit / Ruby + Selenium / Appium + Python (unittest) unit testing framework, open source functional test automation solutions, Selenium / Appium itself can not be tested tool, but only for the machine tool operation browser, tools plus the specified language, allowing the machine to operate the browser, but to this moment, can not do the test, so only the needs of each language own unit testing framework to with the completion of construction of the automated functional testing solutions.

4, automated testing content

Automated test coverage from the UI (functional testing) to contract (interface testing) method and the underlying code (unit testing) of the whole process, in order to grasp a good automated testing, you really need to experience the following three areas:
programming language , object-oriented programming priority, because a large number of open source technology solutions are based on object-oriented programming.
Third-party test tools and test frameworks, learning these documents mainly through the official website.
Means test the concept and design, tools and languages, just to test, how to prepare for the test data, how to set up checkpoints and test step of the test, which determines the success or failure of the test.

5, the development of automated testing

The first generation of automated test about 15 years ago, recording input through the hardware keyboard and a way to play, but the absence of a checkpoint (checkpoint) function, and difficult to maintain test scripts.
The second generation of automated testing is about 10 years ago, and time has been changed from hardware to software through the recording / playback (capture / playback) way to generate test scripts (), and also adds the ability to checkpoint, can be done to verify the software, the scope of testing has been much greater than the hardware of an automated fashion. Big problem is also a test script programming language, so testers need to understand the programming language, in other words, to write the program. And when there are changes in the software, test scripts also need to synchronize updates, which is a big challenge for testers, testers often is the whole test script and then re-record it again.

In 2001, the third generation of automated test called "test framework (test framework)" is used primarily to test scripts to abstraction (abstraction) (Note: Keyword-Driven Test), so that non-technical personnel (such as system analysts, users, etc.) even if do not understand the test script, the case will not write a program, you can also build automated test cases using automated testing tools.
The fourth-generation Mercury Business Process Testing: automated testing focused on business needs. With the continuous improvement of test equipment and test technology, automated testing technology has undergone continuous improvement, improvement and development of the course.

Automated test development trend forecast:
<1>, complex testing tasks, heavy workload, the opposite function test system, the performance put forward higher requirements.
<2>, test speed, high precision, high accuracy measurements.
<3>, timed or long-term continuous test.
<4>, dangerous or difficult to enter the tester's test site.
<5>, extend the life of the test equipment itself.

6, advantages and disadvantages of automated testing

The advantages of automated testing:

a) save manpower, as long as the code of good maintenance, do not need so many people can complete the test
b) to save time, test scripts can be run at night or on weekends test scripts
c) optimize resource allocation, while running the test script, QA can do other things, such as the design of new test cases
d) to facilitate the return, greatly improve the efficiency of
e) increase the reliability of software, testing is performed by the machine, excluding arbitrary or inadvertent result of human emotions that occur when manual testing, the test results more reliable
f) to complete the work by hand difficult to control, such as cpu occupancy information acquisition system, manual calculation is complicated, but also for data comparison, using scripts easier and more convenient.

Automated testing disadvantages:

a) script maintenance costs are high, especially in relatively large changes in the version of the project, the potential risks and
b) difficult to find a new bug

Second, how to carry out an independent web-side automation

1, the mainstream web automated testing tools:

SELENIUM WEB arguably the most comprehensive open source test automation tool that can run on WINDOWS, LINUX, MAC and SOLARIS, and can be built with almost any programming language, you can use your familiar language including JAVA, C # , PERL, PHP, PYTHON and RUBY. It can test browsers IE, FIREFOX, OPERA and SAFARI.
WATIR abroad is another very popular automated testing framework.
WEBDRIVER is another GOOGLE is using automated testing software, language is JAVA

2, Selenium features

<1>, open source, free
<2>, multi-browser support: Firefox, Chrome, IE, Opera, Safari
<3>, multi-platform support: Linux, Windows, Mac
<4>, multi-language support: Java, Python, Ruby, PHP, C #, JavaScript
<5>, there is good support for web page
<6>, simple (simple API), flexible (driving development language)
<7>, support for distributed test case execution

3, Selenium introduce family

selenium RC: selenium Server + Client Libraries . Selenium Server which is responsible for controlling browser behavior. The library is used to control when selenium Server Client Libraries is to test to write test cases.
selenium IDE: interaction record with the browser to create test cases. After that, the player can use the option to re-run the test cases.
selenium CORE: logic executed test code, record test results, the test is completed.
selenium GRID: control multiple machines multiple browsers to execute test cases.

4, Selenium deployment environment

<. 1> python mounted
official website to download python installation package, install and configure the selected path environment variable
<2> mounted PIP
https://pypi.org/project/pip/ the download package
<3> mounted selenium
input pip install -U selenium by mounting pip Selenium
<. 4> mounting browser driver
5 webdriver authentication start the browser and the browser is closed

5, Selenium (WebDriver) principle

Here Insert Picture Description
<1> ,. selenium client (written in languages ​​such as python automated test scripts) to initialize a service service, start the browser driver chromedriver.exe by Webdriver

<2> sent through RemoteWebDriver driver to the browser HTTP request, the browser parses the driver request, opening a browser, and access SessionID, if the browser again need to carry this operation id

<3>, open the browser, bind to a specific port, the post-launch the browser as a remote server webdriver

<4>, open the browser, selenium all operations (access address, find elements, etc.) are linked to the remote server through RemoteConnection, then calls the execute method _request method urlib3 sending a request to remote server

<5>, corresponding to the browser in response to an operation by the content execution request

<6>, then the execution of the operation browser returns the results to the test script via the browser driver

Published 10 original articles · won praise 13 · views 398

Guess you like

Origin blog.csdn.net/weixin_46457203/article/details/104968534