以下是回复:
<div class="input radio_buttons optional challenger_order_selected"><span class="radio"><input class="radio_buttons optional" id="challenger_order_selected_eulcrnhkvss5r0tqtg5obeziwwewdz09ls1usjdodytuditqdmnowe5lskzpmdvbpt0--3fb112e512edd2f77187705cbefeb5c479c85a80" name="challenger[order_selected]" type="radio" value="eUlCRnhkVSs5R0tqTG5obEZIWWEwdz09LS1USjdOdytuditQdmNoWE5LSkZpMDVBPT0=--3fb112e512edd2f77187705cbefeb5c479c85a80" /><label class="collection_radio_buttons" for="challenger_order_selected_eulcrnhkvss5r0tqtg5obeziwwewdz09ls1usjdodytuditqdmnowe5lskzpmdvbpt0--3fb112e512edd2f77187705cbefeb5c479c85a80">54</label></span></div>
<div class="input radio_buttons optional challenger_order_selected"><span class="radio"><input class="radio_buttons optional" id="challenger_order_selected_dennu2ewd3dptc8wl08ya0tkblhtzz09ls1ime5hqw5yenvfmjjdmfkyk3fzse53pt0--12dc0d52ba07f91b2957ce4a64aca7c812087239" name="challenger[order_selected]" type="radio" value="dENnU2Ewd3dpTC8wL08ya0tkblhTZz09LS1IME5hQW5yenVFMjJDMFkyK3FzSE53PT0=--12dc0d52ba07f91b2957ce4a64aca7c812087239" /><label class="collection_radio_buttons" for="challenger_order_selected_dennu2ewd3dptc8wl08ya0tkblhtzz09ls1ime5hqw5yenvfmjjdmfkyk3fzse53pt0--12dc0d52ba07f91b2957ce4a64aca7c812087239">53</label></span></div>
<div class="input radio_buttons optional challenger_order_selected"><span class="radio"><input class="radio_buttons optional" id="challenger_order_selected_zc91djdxcxc3oxflazgvahqxnvbyzz09ls1mcxvtrfp1dtrfuu1jyuntrwpvcuznpt0--004c87cba6be163627a29ecf097145307e875ff0" name="challenger[order_selected]" type="radio" value="ZC91djdXcXc3OXFlazgvaHQxNVBYZz09LS1McXVTRFp1dTRFUU1jYUNtRWpVcUZnPT0=--004c87cba6be163627a29ecf097145307e875ff0" /><label class="collection_radio_buttons" for="challenger_order_selected_zc91djdxcxc3oxflazgvahqxnvbyzz09ls1mcxvtrfp1dtrfuu1jyuntrwpvcuznpt0--004c87cba6be163627a29ecf097145307e875ff0">20</label></span></div>
<div class="input radio_buttons optional challenger_order_selected"><span class="radio"><input class="radio_buttons optional" id="challenger_order_selected_djvlznvtuytgvhhpn1iybnpob1nwut09ls1zwtvfl2vprfe0awdkkzbnwhlcumxrpt0--a3d2052afedd2987a5e31cfb11996ed7b9bb28e5" name="challenger[order_selected]" type="radio" value="djVLZnVtUytGVHhPN1IybnpOb1NWUT09LS1ZWTVFL2VPRFE0aWdKKzBnWHlCUmxRPT0=--a3d2052afedd2987a5e31cfb11996ed7b9bb28e5" /><label class="collection_radio_buttons" for="challenger_order_selected_djvlznvtuytgvhhpn1iybnpob1nwut09ls1zwtvfl2vprfe0awdkkzbnwhlcumxrpt0--a3d2052afedd2987a5e31cfb11996ed7b9bb28e5">244</label></span></div>
<div class="input radio_buttons optional challenger_order_selected"><span class="radio"><input class="radio_buttons optional" id="challenger_order_selected_shbjtuz1ajz5c0xuqxfuutl0bzzwut09ls1iexj0svdlnuzbzhjta2oryvg4utvbpt0--4bcb59d227c1658800f0c2a4d9ca70c59b002d22" name="challenger[order_selected]" type="radio" value="SHBjTUZ1ajZ5c0xuQXFUUTl0bzZWUT09LS1IeXJ0SVdlNUZBZHJTa2orYVg4UTVBPT0=--4bcb59d227c1658800f0c2a4d9ca70c59b002d22" /><label class="collection_radio_buttons" for="challenger_order_selected_shbjtuz1ajz5c0xuqxfuutl0bzzwut09ls1iexj0svdlnuzbzhjta2oryvg4utvbpt0--4bcb59d227c1658800f0c2a4d9ca70c59b002d22">101</label></span></div>
我需要找到列表中244的最高数字和相应的动态值,即#34; djVLZnVtUytGVHhPN1IybnpOb1NWUT09LS1ZWTVFL2VPRFE0aWdKKzBnWHlCUmxRPT0 = - a3d2052afedd2987a5e31cfb11996ed7b9bb28e5&#34;。 你可以帮我解决一下如何为同一个
编写bean-shell答案 0 :(得分:1)
您可以使用XPath Extractor:
示例上面的XPath表达式如下所示:
//div/span/label[not(text() <= ../../preceding-sibling::div/span/label/text()) and not(text() <=../../following-sibling::div/span/label/text())]/../input/@value
免责声明:上述表达式仅适用于您问题中提到的响应数据,如果您的实际响应有不同的标记 - 可能不准确。
<强>证据强>:
警告:XPath表达式是内存和资源密集型的,明智地使用它。
<强>参考强>:
答案 1 :(得分:-1)
将它放在beanshell后处理器中:
import java.util.regex.Matcher;
import java.util.regex.Pattern;
String response = prev.getResponseDataAsString();
Pattern pattern = Pattern.compile("<div class=\"input radio_buttons optional challenger_order_selected\"><span class=\"radio\"><input class=\"radio_buttons optional\" id=\".+?\" name=\"challenger[order_selected]\" type=\"radio\" value=\"(.+?)\" /><label class=\"collection_radio_buttons\" for=\".+?\">(\d+?)</label></span></div>");
Matcher matcher = pattern.matcher(response);
Integer maxLabel, curLabel = 0;
String value = "";
while (matcher.find())
{
curLabel = Integer.valueOf(matcher.group(2));
if(curLabel>maxLabel)
{
maxLabel=curLabel;
value = matcher.group(1);
}
}
vars.put("value", value);