4.1 随机取值

请求的接口参数在并发的时候想给每个并发用户随机分配一个取值,可以使用随机模式randomOccurrence(valueList)方法;valueList为参数列表。

例如:get接口http://172.24.128.45:8088/Common/GetClientInfo?VersionCode=271 的VersionCode希望在并发的时候随机取一个值进行接口请求,脚本如下:

step1、从参数文件中读取获取对应的VsCommon的版本信息

filepath2 = "./resources/VsCommon.csv"

list2 = readCSVFile(filepath2)

global VsCommon

VsCommon = list2[0] ....

step2、在接口的request中使用randomOccurrence(valueList)方法

host = '172.24.128.45:8088'

uri = '/Common/GetClientInfo?VersionCode='+randomOccurrence(VsCommon)

url = 'http://'+host+uri

result = request1.GET(url,None,headers)

附参数csv文件:

results matching ""

    No results matching ""