Extract a form parameter value
Content:
<form action="doit.jsp" method="post"><input type="hidden" name="myHiddenField" value="hidden information">Name: <input name="cn" type="text" value="filled value"><br><input name="myRadioField" value="val1" type="radio">Radio Value 1<br><input name="myRadioField" value="val2" type="radio" checked="checked">Radio Value 2<br><input type="checkbox" name="myCheckbox" value="checkBoxValue" checked="checked">A checkbox<br><select name="dropDownList"><option value="val1">list choice 1<option value="val2" selected>list choice 2<option value="val3">list choice 3</select><br><input value="Send" type="submit"><input type="reset"></form>The form looks like this:
Extract from a text field
Content (value in quotation marks): <input name="cn" type="text" value="filled value">
Regex: <input name="cn" type="text" value="([^"]*)"
Content (value without quotation marks): <input name="cn" type="text" value=myvalue>
Regex: <input name="cn" type="text" value=([^\s>]*)
Comment: In each case, the brackets define the group whose value may be extracted in NeoLoad using $1$.
Advanced case: Where the web page contains several forms with text fields of the same name, the regex must contain the following:
<form action="doit.jsp" method="post">(.|\s)*?<input type=hidden name=myHiddenField value="([^"]*)"Comments:
- (.|\s)*? means "any character, including the new line character". "?" means that the first "<input" must be used.
- ([^"]*) means "any character except the quotation mark character '"' ". The brackets are required to define a group. The first group ($1$ in NeoLoad), refers to ''(.|\s)*". However, the second group ($2$ in NeoLoad) also needs to be taken into account.
Extract from a hidden field
The hidden field is dealt with in a similar way to a normal text field. The input type value "hidden" is substituted for "text".
Content: <input type=hidden name=myHiddenField value="hidden information" >
Regex: <input type=hidden name=myHiddenField value="([^"]*)"
Extract from a radio button
Content: <input name="myRadioField" value="val2" type="radio" checked="checked" >Radio Value 2
Regex: <input name="myRadioField" value="([^"]*)" type="radio" checked="checked" >([^<\n]*)
Comments:
- The radio button selected is the one with the checked attribute set to "checked".
- ([^"]*) means "any character except the quotation mark character '"' ".
- ([^<\n]*)means "any character except '<' and the new line character ".
- The brackets are required to define a group. The first group refers to the value and the second refers to the radio button label. Therefore, use $1$ in NeoLoad to extract the value and $2$ to extract the label.
Extract from a checkbox
Content: <input type="checkbox" value="checkBoxValue" name="myCheckbox" checked="checked">A checkbox
Regex: <input type="checkbox" value="([^"]*)" name="myCheckbox" checked="checked">([^<\n]*)
Comments:
- The checkbox selected is the one with the checked attribute set to "checked".
- ([^"]*)means "any character except the quotation mark character '"' ".
- ([^<\n]*)means "any character except '<' and the new line character ".
- The brackets are required to define a group. The first group refers to the value and the second refers to the checkbox label. Therefore, use $1$ in NeoLoad to extract the value and $2$ to extract the label.
Extract from a list
Content:
<select name="dropDownList"><option value="val1">list choice 1<option value="val2" selected>list choice 2<option value="val3">list choice 3</select>Regex: <select name="dropDownList">(.|\n)*<option value="([^"]*)" selected>([^<\n]*)
Comments:
- The list item selected is the one with the selected attribute set.
- (.|\n)* means "any character, including the new line character".
- [^"]*) means "any character except the quotation mark character '"' ".
- ([^<\n]*)means "any character except '<' and the new line character ".
- The brackets are required to define a group. The first group in the regex is redundant; the second refers to the value and the third to the list item label. Therefore, use $2$ in NeoLoad to extract the value and $3$ to extract the label.
Home