Web automated testing entry

  web automated testing

 

 

version number

Release Notes

updater

Updated

V 1.0

 

 

2019.3.28

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

table of Contents

First, the automated testing basic introduction 2

Two, Web automation tools 3

Three, the Selenium introduces 4

Four, the Selenium WebDriver common API 4

Five, TestNG 6

Six environmental structures 8

First, the automated testing basic introduction

1 automated testing Overview:

What is automated testing? In general all can replace manual testing methods are part of automated testing, that is to simulate the process carried out by people with cases of tools and scripts.

 

2 automated testing role

  • Reduce the software testing time and cost to improve software quality
  • Strengthen testing by expanding test coverage
  • Manual test difficult to complete, requires a higher cost, longer program, higher quality tasks
  • Iterative update less, but still need testers maintenance, through automation of human liberation

 

3 main applications of automated testing:

  • Smoke testing (the main business processes)
  • Regression Testing
  • Performance Testing
  • Compatibility Test (a test script, execute multiple platforms)
  • After completion of the manual testing can not complete the work commute unmanned test

 

4 web automation achievable goals:

(A) principles:

  • Write automated test case library, writing test cases based on use cases use cases inside the library.
  • Improve test efficiency and reduce testing costs
  • Strong repetitive use cases implemented automation
  • Rapid regression testing, to improve the speed and quality of release
  • Functional coverage requirements
  • Having portability and test repeatability

(B) implementation strategies (continuous integration):

  • Select the frame
  • Environment to build
  • case write: public extraction module to extract public parameters, functional logic familiar
  • log output
  • Report Output
  • Jenkins Continuous Integration: integrating timing, send e-mail

Two, Web automation tools

1 web automation tool of choice:

Automation tools on the market is divided into commercial and open source and paid two kinds, offers two main types of the following selenium and QTP contrast

 

 

 

The final selection: the Selenium + IDEA ( the Java + Maven + TestNG ) + Jenkins

Three, the Selenium Introduction

(A) the Selenium Test principle:

 

  • In the automated testing process, there are three parts of components: client-side script + browser driver + browser terminal.
  • Driver files to geckodriver.exe for example, after the executable file to start the drive, the equivalent of a series of exposes server interface, a monitor port .
  • Client operations (access page, positioning elements, the input data, click buttons, etc.) are packaged in a interface request ( EG : / the session / XX / YY ), then submitted to the server drive.
  • After the server receives a drive request from the client, the terminal browser interaction talk.
  • Terminal browser and make the appropriate operation (operating elements, and even the browser itself: screenshots, windows, and install the plug-certificate) .

 

 

 

(B) the Selenium suite of tools brief

  • WebDriver the Selenium : object-oriented API.
  • IDE the Selenium (Integrated Development Environment): FireFox plug-in to provide a graphical interface to record and play back scripts, plug-ins just a prototype tool to simulate, test engineers do not want to use this tool to run test scripts in large quantities. This requires the use of third-party plug-ins javaScript code base to support through the bad judgment and conditions
  • Selenium-Grid can execute multiple concurrent way test environment test scripts to achieve concurrent execution of the script, to shorten the execution time of a large number of test scripts.

Four, the Selenium WebDriver common API

(A) the Selenium WebDriver common foundation API

(A) Browser Operation

  • Load drivers browser , open the page :

driver = new FirefoxDriver();
String baseUrl = "http://oa2.midairen.com/index.html";
driver.get(baseUrl);

  • Close the browser:

driver.close (); // close the browser

  • Maximize the window:

driver.manage().window().maximize();

  • Back to the previous page:

driver.navigate().back();

  • Advance to next page: 

driver.navigate().forward();

  • refresh page: 

driver.navigate().refresh();

  • Obtain title and print

String title =driver.getTitle();

  • Kill Windows browser process
  • The current browser window screenshots (comparative screenshots)
  • Operation of the browser cookie

 

(B)  Page Operations

  • Source code of the page
  • Get the page URL address
  • Clear the original text in the input box
  • Enter the content specified in the input box
  • Click the button
  • Double-click on an element
  • Radio operation drop-down list
  • Operation checkbox
  • Operation box
  • Check the element text content appears
  • Perform JS script
  • Operating iframe page elements
  • Operation Rich Text

 

(Iii)  Method of positioning elements:

 

 

 

Five, TestNG

(A) TestNG basic description:

TestNG is Java test framework, is a very popular practical unit testing framework, a perfect use case management module, with Maven can easily manage third-party plug-ins rely on. Use TestNG can do functions, interfaces, unit, integration of automated testing, the most common is a combination of selenium do automated testing functions, it uses Java annotations to write test methods.

Testers generally use TestNG to write automated tests, developers typically use Junit write unit tests, TestNG for testers of the main reasons : TestNG is more suitable for complex integration testing.

  

(B)  TestNG features:

  • annotation
  • TestNG Java and object-oriented features
  • Support comprehensive test (for example, by default, there is no need to create a new test as an instance of the class for each test method)
  • Separate test code compile time configuration run / data
  • Flexible Runtime Configuration
  • Support dependent test method, parallel test, load test, the partial failure
  • Flexible plugin API
  • Support for multi-threaded test

 

(C)  Note:

TestNG common test method for testing organization of test Suite-test- test class-. Test suite with one or more test composition, test class by one or more test compositions, a test class with one or more test methods composition. When using test cases at different levels, class initialization before the test to achieve different notes, test case execution after cleanup work and testing.

Common annotated as follows:

      

 

 

 

(Iv)  dependence test

     Some complex test scenarios need to be performed in accordance with a specific sequence of test cases, a test case in order to ensure the implementation of a specific order to run this test scenario called dependency needs test. By relying on the test, different test methods for sharing data and program status. Use dependsOnMethods parameters to achieve.

@Test(dependsOnMethods = {"testcase1"})

 

 

(V)  assert

      In the implementation of automated test cases, we need to execute automatically determine whether the output value obtained after the completion of use cases is consistent with the expected value, this time you need to use assertions. TestNG provides a class Assert: org.testng.AsserTestNG provides a Assert class, org.testng.Assert as a container class is a static method of placing a series of assertions.

. The Assert assertTrue (select1.isDisplayed ()); // assert judge select1 element exists in the page

Common assertions:

  • assertTrue: to determine whether to true.
  • AssertFALSE: to determine whether to FALSE.
  • AssertNull: to determine whether the air
  • AssertNoNull: to determine whether not empty
  • AssetEquals: determining whether the same
  • AssertNoEquals: determines whether or not equal

Sixth, environmental structures

See other Bowen: https://www.cnblogs.com/liuzhongzhu/p/11611698.html

 

Guess you like

Origin www.cnblogs.com/liuzhongzhu/p/11611766.html