如何使用 robotframework 执行特定的 HTTP 请求
How to execute specific HTTP request using robotframework
下面的命令将执行 jmx 文件下的所有 HTTP 请求,但我想使用机器人框架在 jmeter 中执行特定的线程组或 HTTP 请求。
下面的关键字将执行所有线程组和 HTTP 请求,
Run Jmeter /home/sadha/Documents/apache-jmeter-5.4.1/bin/jmeter.sh /home/sadha/Documents/apache-jmeter-5.4.1/bin/HTTP Request.jmx ${logPath} -Jvendor=${vendor} -Jurl=${url} -Jport=${port}
对于 Thread Group - if you dynamically define the number of threads using __P() function 在 2 个线程组中,例如:
- 在线程组 1 中:
${__P(thread.group.1.users,)}
- 在线程组 2 中:
${__P(thread.group.2.users,)}
您将能够通过 -J
command-line argument 提供所需的线程数,例如:
- 运行 线程组 1 有 100 个用户,不要 运行 线程组 2:
/home/sadha/Documents/apache-jmeter-5.4.1/bin/jmeter.sh /home/sadha/Documents/apache-jmeter-5.4.1/bin/HTTP Request.jmx ${logPath} -Jvendor=${vendor} -Jurl=${url} -Jport=${port} -Jthread.group.1.users=100 -Jthread.group.2.users=0
- 运行 线程组 2 有 100 个用户,不要 运行 线程组 1:
/home/sadha/Documents/apache-jmeter-5.4.1/bin/jmeter.sh /home/sadha/Documents/apache-jmeter-5.4.1/bin/HTTP Request.jmx ${logPath} -Jvendor=${vendor} -Jurl=${url} -Jport=${port} -Jthread.group.1.users=0 -Jthread.group.2.users=100
- 运行 两个线程组各有 100 个用户:
/home/sadha/Documents/apache-jmeter-5.4.1/bin/jmeter.sh /home/sadha/Documents/apache-jmeter-5.4.1/bin/HTTP Request.jmx ${logPath} -Jvendor=${vendor} -Jurl=${url} -Jport=${port} -Jthread.group.1.users=100 -Jthread.group.2.users=100
相同的方法可以应用于 HTTP 请求采样器,如果将它们放在 Switch Controller 下并使用 __P() 函数作为开关值,如 ${__P(request,)}
:
- 如果你通过
-Jrequest="Request 1"
- 它会执行 Request 1
- 如果你传递
-Jrequest="Request 2"
- 它会执行 Request 2
- 等等
更多信息:
下面的命令将执行 jmx 文件下的所有 HTTP 请求,但我想使用机器人框架在 jmeter 中执行特定的线程组或 HTTP 请求。
下面的关键字将执行所有线程组和 HTTP 请求,
Run Jmeter /home/sadha/Documents/apache-jmeter-5.4.1/bin/jmeter.sh /home/sadha/Documents/apache-jmeter-5.4.1/bin/HTTP Request.jmx ${logPath} -Jvendor=${vendor} -Jurl=${url} -Jport=${port}
对于 Thread Group - if you dynamically define the number of threads using __P() function 在 2 个线程组中,例如:
- 在线程组 1 中:
${__P(thread.group.1.users,)}
- 在线程组 2 中:
${__P(thread.group.2.users,)}
您将能够通过
-J
command-line argument 提供所需的线程数,例如:- 运行 线程组 1 有 100 个用户,不要 运行 线程组 2:
/home/sadha/Documents/apache-jmeter-5.4.1/bin/jmeter.sh /home/sadha/Documents/apache-jmeter-5.4.1/bin/HTTP Request.jmx ${logPath} -Jvendor=${vendor} -Jurl=${url} -Jport=${port} -Jthread.group.1.users=100 -Jthread.group.2.users=0
- 运行 线程组 2 有 100 个用户,不要 运行 线程组 1:
/home/sadha/Documents/apache-jmeter-5.4.1/bin/jmeter.sh /home/sadha/Documents/apache-jmeter-5.4.1/bin/HTTP Request.jmx ${logPath} -Jvendor=${vendor} -Jurl=${url} -Jport=${port} -Jthread.group.1.users=0 -Jthread.group.2.users=100
- 运行 两个线程组各有 100 个用户:
/home/sadha/Documents/apache-jmeter-5.4.1/bin/jmeter.sh /home/sadha/Documents/apache-jmeter-5.4.1/bin/HTTP Request.jmx ${logPath} -Jvendor=${vendor} -Jurl=${url} -Jport=${port} -Jthread.group.1.users=100 -Jthread.group.2.users=100
- 在线程组 1 中:
相同的方法可以应用于 HTTP 请求采样器,如果将它们放在 Switch Controller 下并使用 __P() 函数作为开关值,如
${__P(request,)}
:- 如果你通过
-Jrequest="Request 1"
- 它会执行Request 1
- 如果你传递
-Jrequest="Request 2"
- 它会执行Request 2
- 等等
- 如果你通过
更多信息: