软件测试面试刷题,这个小程序(永久刷题),靠它可以快速找到工作!https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502
https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502
日常测试过程中会遇到要测试并发情况下的页面加载时间。今天就在大家写好的playwright脚本基础上直接使用yaml就可以完成性能测试了。
以下是一个完整的示例,展示如何在访问多个网页之前设置 cookie,并进行加载时间测试。
完整的 Playwright 测试脚本(设置 Cookie)
创建一个 Playwright 测试脚本,例如 playwright_test.py:
from playwright.sync_api import sync_playwright
import time
def measure_load_time(page, url):
start_time = time.time()
page.goto(url)
page.wait_for_load_state('load')
load_time = time.time() - start_time
print(f"Loaded {url} in {load_time:.2f} seconds")
return load_time
def run(playwright):
browser = playwright.chromium.launch()
context = browser.new_context()
# 设置 Cookie
cookies = [
{
'name': 'example_cookie',
'value': 'cookie_value',
'domain': 'example.com',
'path': '/',
'httpOnly': False,
'secure': False
}
]
context.add_cookies(cookies)
page = context.new_page()
urls = [
'https://example.com',
'https://example.com/about',
'https://example.com/contact'
]
for url in urls:
measure_load_time(page, url)
browser.close()
with sync_playwright() as playwright:
run(playwright)
配置 Taurus
创建一个 Taurus 配置文件,例如 taurus_playwright.yml:
execution:
- executor: shellscript
concurrency: 10
hold-for: 5m
scenario: playwright_test
scenarios:
playwright_test:
script: ./run_playwright.sh
创建 Shell 脚本来执行 Playwright 测试
创建一个名为 run_playwright.sh 的 Shell 脚本,内容如下:
#!/bin/bash
python playwright_test.py
给脚本执行权限:
chmod +x run_playwright.sh
运行测试
使用以下命令运行 Taurus 测试:
bzt taurus_playwright.yml
配置文件详细说明
在 taurus_playwright.yml中:
- execution: 定义执行配置。
- executor: 使用 shell脚本 作为执行器来运行 Playwright 测试。
- concurrency: 设置并发用户数(浏览器实例)。
- hold-for: 设置测试持续时间。
- iterations: 设置每个用户执行的迭代次数。
- scenario: 指定测试场景名称。
- scenarios: 定义具体的测试场景。
- script: 指定 Playwright 测试脚本的位置。
- `browser`: 指定浏览器(如 `chromium`)。
示例项目结构
确保你的项目结构如下:
your-project/
├── playwright_test.py
├── run_playwright.sh
├── taurus_playwright.yml
└── venv/
└── (virtual environment files)
运行测试的结果
在执行 `bzt taurus_playwright.yml` 命令后,Taurus 将启动多个浏览器实例来运行 Playwright 测试脚本,并生成包含并发用户性能指标的报告。报告会显示响应时间、成功率、错误率等关键性能指标。
提示
1. 资源要求:运行大量并发浏览器实例可能需要相当多的计算资源。确保你的机器有足够的内存和 CPU 能力,或者使用云服务来分配更多的资源。
2. 报告和监控:Taurus 会生成 HTML 报告,可以在测试完成后查看。默认情况下,报告会保存在当前目录下的 bzt-文件夹中。
通过这些步骤,你可以使用 Taurus 和 Playwright 集成进行多个网页的加载时间测试,并在测试过程中设置页面的 cookie。这样,你可以更加真实地模拟用户场景,评估网页在高并发情况下的性能表现。
最后: 下方这份完整的软件测试视频教程已经整理上传完成,需要的朋友们可以自行领取【保证100%免费】
软件测试面试文档
我们学习必然是为了找到高薪的工作,下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料,并且有字节大佬给出了权威的解答,刷完这一套面试资料相信大家都能找到满意的工作。