在Python中,我编写了一个脚本来模拟客户下订单。它将包括创建订单、向其中添加行,然后签出。我现在正在做这样的事情:
api = ['login', 'createOrder', 'scanBarCode', 'addLine', 'checkout']
for apiName in apiList:
#call API
我把它设计成一个框架,这样在情况发生变化时添加新的api就很容易了。我的设计问题是:如何对它进行编码,以便可以多次调用scanBarCode和addLine?比如:
api = ['login', 'createOrder', 'scanBarCode', 'addLine', 'checkout']
numberOfLines = (random number)
for apiName in apiList:
#call API
#if API name is scanBarCode, repeat this and the next API numberOfLines times, then continue with the rest of the flow
使用range或(最好)xrange循环:
应该从以下内容开始:
相关问题 更多 >
编程相关推荐