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支持多种多样的监听器,可以根据自己的需求选择。
    在本例中,我们将使用"表格结果"监听器来查看运行结果。
相关推荐
nothing&nowhere9 小时前
用 Python 做问卷数据清洗:无效样本检测与处理实战
开发语言·python·数据清洗·数据处理·问卷星·问卷星脚本·刷问卷
花酒锄作田9 小时前
如何发布自己的 Python 库到 PyPI
python
researcher-Jiang9 小时前
Design Patterns——Template Method入门到情景实战
python·设计模式·模板方法模式
飞猪~13 小时前
LangChain python 版本 第一集
开发语言·python·langchain
2601_9563198814 小时前
最新AI量化提效,先做可验证的小流程
人工智能·python
开飞机的舒克_15 小时前
FastAPI 实战入门:从路由、参数校验到依赖注入的后端开发指南
python·fastapi
霸道流氓气质15 小时前
Kiro 中反编译 JAR 包并分析字节码的流程指南
chrome·python·jar
人工智能时代 准备好了吗16 小时前
AI回答内容进入率监测:引用识别、文本匹配与语义判断
开发语言·人工智能·python
Metaphor69216 小时前
使用 Python 冻结 Excel 文件中的行、列和单元格
开发语言·python·excel