High-quality goods to丨Software testing enterprise-level Web automation testing project actual combat (with complete project)

Today I will share with you a simple and easy-to-operate practical project (open source)

project name

ET open source shopping mall system

project description

ETshop is an e-commerce B2C e-commerce platform system with powerful functions, safety and convenience. It is suitable for enterprises and individuals to quickly build personalized online shopping malls.

Including PC+IOS client+Adroid client+micro mall, the system PC+background is a cross-platform open source software developed based on the ThinkPHP MVC framework, which is very flexible in design, has a modular architecture system and rich functions, and is easy to integrate with third-party application systems Seamless integration, in terms of design, includes quite comprehensive, with a modular architecture system, so that the application combination becomes quite flexible and the functions are quite rich.

Goals

1. Demand Analysis

2. Select functions suitable for automated testing

3. Design test cases

4. Build an automated test environment [optional]

5. Design the architecture of the automated test project [optional]

6. Write the code

7. Execute the test case

8. Generate test reports and analyze results

project structure

use case design

Master how to write automated test case documents

Principles of writing automated test cases

Automated test cases generally only implement core business processes or functions with a high repetition rate.

The selection of automated test cases is generally based on the verification of "forward" logic.

Not all manual use cases can be performed using automated testing.

Minimize dependencies between multiple use case scripts.

After the automated test case is executed, it is generally necessary to return to the origin.

Write test cases

Project build

1. Create a new project

Project name: webAutoTestETshop

2. Create directory structure

Install the selenium package

Install the parameterized package to add HTMLTestRunner

initialization code

Encapsulation driver class

Encapsulate PO base class, define BasePage and BaseHandle

Write code

Target

1. Master how to use the layered thinking of the PO model to package the page

2. Master how to use UnitTest to manage test cases in the project

Extract PO

Analyze the function to be tested according to the use case and extract the page object

1. Define the page object file

Login page: login_page.py Homepage: index_page.py

Background page (personal center page): home_page.py Product search page: goods_search_page.py Product detail page: goods_detail_page.py Shopping cart page: cart_page.py

Order page: order_page.py

Order payment page: order_pay_page.py My order page: my_order_page.py

1. Write codes for the object library layer, operation layer, and business layer respectively

2. Write test scripts

1. Define the test script file

Login module: test_login.py Shopping cart module: test_cart.py Order module: test_order.py

3. Execute the test script

1. Use unittest to execute the test script

2. Debug code

perfect code

Target

1. Master how to apply data-driven to projects

2. Be able to apply the log collection function to the project

3. Master how to use UnitTest to generate test reports

data driven

Define data files

Define the directory for storing test data, directory name: data

Sub-module definition data file

Login module: login.json Shopping cart module: cart.json Order module: order.json

1. Write use case data according to business

1.2 Test data parameterization

Modify the test script and use parameterized to achieve parameterization

log collection

Use the logging module to collect logs

import logging.handlers import os

# Project directory

BASE_DIR = os.path.dirname(os.path.abspath( file ))

def init_log_config(): """

Initialize log configuration

"""

# log output format

fmt = "%(asctime)s %(levelname)s [%(filename)s(%(funcName)s:%(lineno)d)] - %(messag e)s"

# Create a logger

logger = logging.getLogger() logger.setLevel(logging.INFO)

# create formatter

formatter = logging.Formatter(fmt)

# Output to console

sh = logging.StreamHandler() sh.setFormatter(formatter) logger.addHandler(sh)

# Output to file, one file per day

log_path = os.path.join(BASE_DIR, "log", "tpshop.log")

fh = logging.handlers.TimedRotatingFileHandler(log_path, when='MIDNIGHT', interval=1

, backupCount=3) fh.setFormatter(formatter) logger.addHandler(fh)

Generate test report

Generate test reports using HTMLTestRunner

report_file = "./report/report{}.html".format(time.strftime("%Y%m%d-%H%M%S")) with open(report_file, "wb") as f:

runner = HTMLTestRunner(f, title="ET mall automation test report", description="Win10.Fire

fox")

runner.run(suite)

Welfare

Due to space limitations, it is impossible to elaborate on the entire project one by one. Friends who need this web automation testing project can leave a message in the comment area to receive it for free.

I've seen this, give me a thumbs up and leave

Guess you like

Origin blog.csdn.net/a448335587/article/details/121427387#comments_25911913