想必大家都知道QTP Addin的成本之高,所以如何避免使用付费Addin来测试需求对象是解决成本的最佳方案。
面对WebService,我们可以用到 WinHTTP协议(微软windows HTTP服务),这是一个非常高级别的HTTP协议接口。
以下会具体介绍下这个COM对象。
1.创建WinHttp对象
Object.Open Method,URL,Async
Open – opens a connection to an HTTP resource.
Method – specifies the HTTP verb used for the open method, like ‘GET’,’PUT’,’POST’ etc
URL – the name of the resource
Async – indicates whether to open in asynchronous mode.
Object.SetRequestHeader Header,Value
SetRequestHeader – adds, changes, or deletes an HTTP request header
Header- Specifies the name of the header to be set like depth,Content type, Content length etc.
Value-specified the value of header.
Object.Send Body
Send – sends an HTTP request to an HTTP server.
Body – is the data to be sent to the server.
运行以上脚本,最终会返回 77