动作函数-web_submit_data

web_submit_data("login.pl",

        "Action=http://127.0.0.1:1080/WebTours/login.pl",

        "Method=POST",

        "TargetFrame=body",

        "RecContentType=text/html",

        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home",

        "Snapshot=t3.inf",

        "Mode=HTML",

        ITEMDATA,

        "Name=userSession", "Value=118025.184447145zAHAQcAptcfDztcfpfccff", ENDITEM,

        "Name=username", "Value=jojo", ENDITEM,

        "Name=password", "Value=bean", ENDITEM,

        "Name=JSFormSubmit", "Value=off", ENDITEM,

        "Name=login.x", "Value=58", ENDITEM,

        "Name=login.y", "Value=2", ENDITEM,

        LAST);
StepName:自定义函数名称

Action:提交数据时需要访问的http地址。语法:"Action=" 

Method: 表单提交方法: POST 或 GET (默认: POST).
EncType: 方法使用的编码
Enctype属性指明了Content-Type请求头的value值,具体如下:
"EncType=application/x–www–form–urlencoded"
"EncType=multipart/form–data"  
"EncType=" (空字符串,表明请求不含"Content–Type" 请求头).
 
如果指定了“EncType”,那么它将会覆盖web_add_[auto_]header函数指定的Content-Type。如果省略了“EncType”时,那么使用web_add_[auto_]header函数指定的。

如果既没有指定EncType也没使用web_add_[auto_]header函数设定请求头,且“Method=POST”,那么,将使用“application/x-www-form-urlencoded”做为默认值。

如果Method不是POST,那将不会生成Content-Type请求头。

EncodeAtSign: 编码"@"符号为其ASCII表示.可选值为 Yes 或 No.
TargetFrame: 包含当前链接、资源的frame
Referer: 所引用web页面的url
Mode: 录制级别:HTML 或 HTTP. Click here for more information.
UserAgent: 标识一个组件替代浏览器来执行函数,比如浏览器的ActiveX组件。函数将为该请求添加UserAgent头。

不对该UserAgent是否匹配浏览器User-Agent运行时设置做任何确认检查。

ITEMDATA: 分隔属性列表和和数据列表的标识
List of Data:定义了表单数据。data域包含所有隐藏(携带hidden属性)的表单数据。

数据域。
数据域的值可以加密后的(encrypted)或者是原始的(plain),如下:
"name=n1", "value=v1", ENDITEM,
"name=n2", "EncryptedValue=qwerty", ENDITEM, 
EXTRARES:表明接下来的参数为资源属性列表。

 
List of Resource Attributes: 资源属性列表
当录制在当前脚本的step中时,额外的资源被当作参数列出,支持以下资源属性:
URL       需要加载的web资源
Referer   URL引用的web页面
ENDITEM   表示list中,每个资源结束的标记
非HTML资源,如.gif 和.jpg 图片,仅在资源录制选项设置为Record within the current script step时,才会插入到当前函数中,如下:

LAST  暗示属性列表结束。 
action函数,执行"unconditional" or "contextless" 表单提交。允许发送GET 和 POST的HTML表单请求。

示例代码

例1:上传文件
web_submit_data("choujiang",

        "Action=http://xxx.xxx.x.xx:xxx/ditui/fileupload",

        "Method=POST",

        "Resource=0",

        "RecContentType=application/json",

        "Referer=",

        "Mode=HTML",

        "EncType=multipart/form-data",

         ITEMDATA,

         "Name=MultiPart File","Value=E://test_pic.png", "File=yes", ENDITEM,

        LAST);
原文地址:https://www.cnblogs.com/lvchengda/p/12626031.html