kamal
kamal

Reputation: 9785

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

I have a checkbox in the DOM rendered as:

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

Now, when i "inspect" the page, the selection of the checkbox changes the input to:

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

In JMeter, I want to be able to send a POST request with Parameters ( Name, Value ) to change the title to "Deselect all rows in this table" but I am unable to figure out how to "Set" the value. Since using Regular Expression Extractor, I can only do the substitution as ${CBtitle} if, let's say I have a Regex Extractor: name of created variable: CBtitle

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

So this Regex would be true and can be used as ${CBtitle}, BUT, how can we change the value of title to "Deselect all rows in this table" making the checkbox, selected.

If I use the "Default Value" as "Deselect all rows in this table" it does show as:

CBtitle=Deselect all rows in this table

but, it does not seem to select the checkbox.

Before Checkbox is selected:

<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}}}">

After Checkbox is selected:

<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="">

Upvotes: 0

Views: 282

Answers (1)

Dmitri T
Dmitri T

Reputation: 168157

JMeter doesn't "check" the boxes as it happens solely on client side, neither it can manipulate DOM

If "clicking" the checkbox triggers a HTTP Request - you can capture the request using JMeter's HTTP(S) Test Script Recorder or JMeter Chrome Extension

If clicking the checkbox doesn't generate a HTTP Request - you won't be able to test it using JMeter, you will need a real browser for this so it's better to take a look at browser automation framework like Selenium. If you prefer to stay with JMeter there is WebDriver Sampler plugin which provides JMeter integration with Selenium

Upvotes: 1

Related Questions