Python implementation parse LR analyse result and generate summary performance metrics Data Report

Source: Internet
Author: User

a preface

In the performance test framework development, you need to process the completed test report of the scene, summarize the performance metrics data that you are following in the report, and then write the report and send the relevant person a message. So, one of the steps is how to capture the data from the test report (e.g.,TPS, Response time, number of concurrent users, etc.).

Two problem analysis

when LR generates a test report, it saves the report data to the table of contents, which has a summary of similar metrics, as shown in. However, this idea will disappoint you if you want to get the data for each metric by parsing the HTML! Because analysis of the HTML source discovery, the indicator data is not actually in the page, but in the definition of the page frameset. In layman's words, a page is nested in another page, and the actual data is obtained by accessing the inline page. Familiar with selenium classmate, must know this kind of situation, after all want to locate the element, the first thing to do is switch_to_frame . Not much here, follow-up will be a series of selenium related articles.

three solution ideas

after the analysis of HTML source code, you can find that each indicator data corresponds to an HTML file stored in the report directory , as long as the use of python html The parsing technique gets, and then modifies the data slightly, adding a number of HTML-formatted strings in the form of a label , and finally writing to the. html file.

four Python HTML Parsing technology summary

Python is very good at parsing html , many methods, summed up the following several:

1. lxml.html

2. BeautifulSoup

3. Sgmlparser

4. Htmlparaer

5. requests-html

6. Regular Expressions

in this implementation, the use ofBeautifulSoup, a model forfromHTMLorXMLfiles that extract data from thePythonLibrary,APIclear and concise. Among them,LRthe table styles in the report and the code to get the tabular data are as follows:

Style table for LR reports

Some of the code is as follows:


Five implementation effect

Finally, we analyze the results of the scene execution and extract TPS, Response time, number of concurrent users and other metrics data, and the style for generating summary reports is as follows:


Other resources:

Python Introductory course:http://i.youku.com/weiworld521


Python implementation parse LR analyse result and generate summary performance metrics Data Report

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.