用户浏览的 HTML 页可能会包含表单。一些表单元素可能会以 URL 作为值。
本节分为下列各小部分:
<Form name="form1" field="visit" [valuePatterns="" source="*"]/>
其中
name 是表单的名称(强制项)
field 是表单中的字段,其中含有需要重写的值(强制项)
valuePatterns 参见在规则中使用模式匹配
source 是该表单定义所在 html 页的 URL(可选项,默认值是 *,指在任何页中)
假定页的基 URL 为:
http://test.siroe.com/testcases/html/form.html
页内容
假定页 URI 是 form.html,并且它位于服务器的根目录下。
<form name=form1 method=POST action= "http://test.siroe.com/testcases/html/form.html"> <input type=hidden name=abc1 value="0|1234|/test.html"> </form>
要重写 form1 中名为 abc1 的隐藏字段值中出现的 /text.html,需要下列规则。
规则
<Form source="*/form.html" name="form1" field="abc1" valuePatterns="0|1234|"/> <Attribute name="action"/>
输出
<FORM name="form1" method="POST" action="gateway-URL/ http://test.siroe.com/testcases/html/form.html"> <input type=hidden name=abc1 value="0|1234|gateway-URL/ http://test.siroe.com/test.html"> </FORM>
描述
action 标记是用某些已定义的 HTML 属性规则进行重写的。
输入标记属性值的 value 的重写方式如输出中所示。将会查找指定的 valuePatterns,并通过在前面加上网关 URL 以及页的基 URL 来重写紧随在匹配的 valuePatterns 之后的所有内容。参见在规则中使用模式匹配。