selenium +Jmeter 的性能测试

通过Jmeter快速将已有的Selenium 代码以性能测试的方式组织起来,并使用JMeter 丰富的报表展示测试结果

python 复制代码
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
ActionChains(driver).click(driver.find_element(By.XPATH,"//*[text()='新闻']")).perform()

打开JMeter 创建一个【线程组】

  1. 修改线程数
  1. 右击BaiduSearch线程组,创建BeanShell取样器:

  2. 然后在Script区域填入脚本,设置Bean Shell取样器的信息:

python 复制代码
Process proc = Runtime.getRuntime().exec("python F:/pythonProject1/AutomaticTesting/single.py"); 
// Process proc = Runtime.getRuntime().exec("cmd /c python "+"python F:/pythonProject1/AutomaticTesting/single.py"); 
proc.waitFor();
  1. 创建监听器并运行
    基本的性能测试就组织好了,接下来可以创建监听器来查看运行结果。JMeter支持多种多样的监听器,可以根据自己的需求选择。
    在本例中,我们将使用"表格结果"监听器来查看运行结果。
相关推荐
winfredzhang3 分钟前
构建自动化 Node.js 项目管理工具:从文件夹监控到一键联动运行
chrome·python·sqlite·node.js·端口·运行js
AI_56786 分钟前
Airflow“3分钟上手”教程:用Python定义定时数据清洗任务
开发语言·人工智能·python
Aurora-Borealis.16 分钟前
Day 38 GPU训练和call方法
python
Ulyanov17 分钟前
PyVista三维战场仿真实战
开发语言·python·tkinter·pyvista·gui开发
深蓝电商API17 分钟前
Scrapy爬虫部署到Scrapyd服务端详解
爬虫·python·scrapy
无垠的广袤22 分钟前
【工业树莓派 CM0 NANO 单板计算机】YOLO26 部署方案
linux·python·opencv·yolo·树莓派·目标识别
STLearner23 分钟前
AAAI 2026 | 时间序列(Time Series) 论文总结[下] (分类,异常检测,基础模型,表示学习,生成)
大数据·论文阅读·人工智能·python·深度学习·机器学习·数据挖掘
科研鬼才(bushi31 分钟前
项目文件夹规范
python
程序员:钧念40 分钟前
深度学习与大语言模型LLM的区别
人工智能·python·深度学习·语言模型·自然语言处理·transformer·agent
深蓝电商API42 分钟前
Scrapy Feed Exports 进阶:多种格式导出配置
爬虫·python·scrapy