如何在 JMeter "Http Request" 中更改带有 "title" 文本控制状态的复选框的参数值

How to Change the Parameter Value in JMeter "Http Request" for a checkbox with "title" text controlling the state

我在 DOM 中有一个复选框呈现为:

<input type="checkbox" class="form-checkbox" title="Select all rows in this table">

现在,当我“检查”页面时,复选框的 selection 将输入更改为:

<input type="checkbox" class="form-checkbox" title="Deselect all rows in this table">

在 JMeter 中,我希望能够发送带有参数(名称、值)的 POST 请求,以将标题更改为“Deselect 此 table 中的所有行”,但我无法弄清楚如何“设置”该值。由于使用正则表达式提取器,我只能将替换作为 ${CBtitle} 如果,假设我有一个正则表达式提取器: 创建变量的名称:CBtitle

Regular Expression: class="form-checkbox" title="(.*)"
Template: $
Match No: 
Default Value:

所以这个正则表达式是正确的,可以用作 ${CBtitle},但是,我们如何改变 标题的值为“Deselect all rows in this table”使复选框,selected.

如果我将“默认值”用作“Deselect 此 table 中的所有行”,它会显示为:

CBtitle=Deselect 此 table

中的所有行

但是,它似乎没有 select 复选框。

在 select 编辑复选框之前:

<input class="display-inline form-text usa-input" data-drupal-selector="edit-unit-id" 
aria-describedby="edit-unit-id--description" data-msg-maxlength="Establishment/Unit Number  
field has a maximum length of 128." type="text" id="edit-unit-id" name="unit_id" value="" 
size="60" maxlength="128" 
data-drupal-states="{&quot;disabled&quot;:{&quot;:input[name=\u0022id_check\u0022]&quot;:{&quot;checked&quot;:true}}}">

select编辑复选框后:

<input class="display-inline form-text usa-input" data-drupal-selector="edit-unit-id" 
aria-describedby="edit-unit-id--description" data-msg-maxlength="Establishment/Unit Number  
field has a maximum length of 128." type="text" id="edit-unit-id" name="unit_id" 
value="" size="60" maxlength="128" 
data-drupal-states="{&quot;disabled&quot;:{&quot;:input[name=\u0022id_check\u0022]&quot;:{&quot;checked&quot;:true}}}" disabled="">

JMeter 不会“检查”这些框,因为它只发生在客户端,它也不能操纵 DOM

如果“单击”复选框会触发 HTTP Request - you can capture the request using JMeter's HTTP(S) Test Script Recorder or JMeter Chrome Extension

如果单击复选框不会生成 HTTP 请求 - 您将无法使用 JMeter 对其进行测试,为此您需要一个真正的浏览器,因此最好查看浏览器自动化框架,例如 Selenium. If you prefer to stay with JMeter there is WebDriver Sampler 提供 JMeter 与 Selenium 集成的插件