当前位置:网站首页>Interface test advanced interface script use - apipost (pre / post execution script)
Interface test advanced interface script use - apipost (pre / post execution script)
2022-07-08 00:35:00 【InfoQ】

- To write JS Functions to achieve complex calculations ;
- Variable printing
- Definition 、 obtain 、 Delete 、 Clear environment variables
- Definition 、 obtain 、 Delete 、 Clear global variables
- Get request parameters
- Dynamic addition 、 Delete one header Request parameters
- Dynamic addition 、 Delete one query Request parameters
- Dynamic addition 、 Delete one body Request parameters
- send out HTTP request

function _random(){
return ' Hello , China ' + Math.random();
}apt.globals.set("random_var", _random());
apt.variables.set("key", "value"); // Set a value to value Environment variables of key
apt.variables.get("key"); // Get environment variables key Value
apt.variables.delete("key"); // Delete environment variables key
apt.variables.clear(); // Clear all defined environment variables apt.globals.set("key", "value"); // Set a value to value Global variable of key
apt.globals.get("key"); // Set a value to value Global variable of key
apt.globals.delete("key"); // Set a value to value Global variable of key
apt.globals.clear(); // Clear all defined global variables apt.setRequestHeader("key", "value"); // Dynamically add a key to key The value is value Of header Parameters
apt.removeRequestHeader("key"); // Delete header The key in the parameter is key Parameters of apt.setRequestQuery("key", "value"); // Dynamically add a key to key The value is value Of query Parameters
apt.removeRequestQuery("key"); // Delete query The key in the parameter is key Parameters of apt.setRequestBody("key", "value");// Dynamically add a key to key The value is value Of body Parameters Only aim at form-data、urlencode It works
apt.removeRequestBody("key");// Delete body The middle key is key Parameters of Only aim at form-data、urlencode It works $.ajax({
url:"https://echo.apipost.cn/get.php",
method:"POST",
headers:{
"content-type":"application/json"
},
timeout:"10000",
async:false, // Remember that this is set to false, The request must be synchronized
data:JSON.stringify({"email":"[email protected]","password":"123456"}),
success:function (response) {
apt.globals.set("bigint",response.bigint);
}
}边栏推荐
- 接口测试要测试什么?
- Is Zhou Hongyi, 52, still young?
- Binder核心API
- Deep dive kotlin collaboration (the end of 23): sharedflow and stateflow
- The difference between get and post
- 韦东山第三期课程内容概要
- 第一讲:链表中环的入口结点
- ABAP ALV LVC template
- [basis of recommendation system] sampling and construction of positive and negative samples
- 浪潮云溪分布式数据库 Tracing(二)—— 源码解析
猜你喜欢

Reentrantlock fair lock source code Chapter 0

Service Mesh介绍,Istio概述

【测试面试题】页面很卡的原因分析及解决方案
![[OBS] the official configuration is use_ GPU_ Priority effect is true](/img/df/772028e44776bd667e814989e8b09c.png)
[OBS] the official configuration is use_ GPU_ Priority effect is true

《因果性Causality》教程,哥本哈根大学Jonas Peters讲授

How to learn a new technology (programming language)

paddle一个由三个卷积层组成的网络完成cifar10数据集的图像分类任务

Play sonar

Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
![Cause analysis and solution of too laggy page of [test interview questions]](/img/8d/3ca92ce5f9cdc85d52dbcd826e477d.jpg)
Cause analysis and solution of too laggy page of [test interview questions]
随机推荐
paddle入门-使用LeNet在MNIST实现图像分类方法一
攻防演练中沙盘推演的4个阶段
ABAP ALV LVC template
如果在构造函数中抛出异常,最好的做法是防止内存泄漏?
8道经典C语言指针笔试题解析
Emotional post station 010: things that contemporary college students should understand
Kubernetes Static Pod (静态Pod)
After going to ByteDance, I learned that there are so many test engineers with an annual salary of 40W?
[C language] objective questions - knowledge points
从服务器到云托管,到底经历了什么?
redis你到底懂不懂之list
Introduction to paddle - using lenet to realize image classification method I in MNIST
How does starfish OS enable the value of SFO in the fourth phase of SFO destruction?
RPA云电脑,让RPA开箱即用算力无限?
【obs】Impossible to find entrance point CreateDirect3D11DeviceFromDXGIDevice
How can CSDN indent the first line of a paragraph by 2 characters?
ReentrantLock 公平锁源码 第0篇
How to add automatic sorting titles in typora software?
Play sonar
Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department