soapui断言和变量

soapui断言和变量

soapui与xpath有非常紧密的关系

xpath学习路径:http://www.w3school.com.cn/xpath/xpath_syntax.asp

供学习使用的WSDL文件

http://www.webxml.com.cn/WebServices/TrainTimeWebService.asmx?wsdl

对外公开的接口,可以直接从网上找到(仅供学习,不要商用) 

一、新建一个soupui项目,在”Initial WSDL/WADL”对应的输入框中输入WSDL地址,一直点击”OK”;

二、双击项目名称查看项目信息;

三、右击” getStationAndTimeByStationName TestCase”->”Add Step”->” Properties”

1.  点击”+”添加properties;

2.  在此处添加”StartStation:武汉”,” ArriveStation: 赤壁北”

3.  此处一定要注意properties一定要放在接口前,否则接口无法获取;

四、双击打开” getStationAndTimeByStationName ”接口,StartStation的值输入${ StartStation }, ArriveStation的值输入${ArriveStation},运行接口查看结果;

五、为” getStationAndTimeByStationName TestCase”接口添加”XPath Match”断言,添加完成后点击”Test”测试一下结果是否正确;

1.  Declare: exists(//StartStation[contains(text(),'${StartStation}')]) 

      Expected Result:true

2.  Declare: //exists(//getStationAndTime/TimeTable/FirstStation)  Expected Result:true

3.  Declare: exists(//getStationAndTime/TimeTable/TrainCode)  Expected Result:true

如果断言正确,则断言图标为绿色否则为红色

六、将” getDetailInfoByTrainCode”接口复制到” getStationAndTimeByStationName TestCase”目录

1. 选中” getDetailInfoByTrainCode”接口右击选择”Clone TestCase”;

2.  输入” TestCase Name”;

3. 选择”Target Project”;

4.选择” Target TestSuite”;

5.选择”Target TestCase”: ” getStationAndTimeByStationName TestCase”

6. 点击”OK”

七、右击” getStationAndTimeByStationName TestCase”选择添加”Add Step”à”Property Ttransfer”,添加完成后运行查看结果

1.输入名称:transferTotrainCode  Source: //getStationAndTime/TimeTable/TrainCode[1]

”Source”: getStationAndTimeByStationName

”Property”:Response

”Target”: Properties

”property”:TrainCode

注:之前一定需要在Properties中添加TrainCode变量

完成后查看运行结果:D2101

查看Properties中TrainCode值为D2101

2.输入名称:transferToarriveTime 

Source: //ArriveStation[text()='${ArriveStation}']/../ArriveTime

”Source”: getStationAndTimeByStationName

”Property”:Response

”Target”: Properties

”property”: ArriveTime

注:之前一定需要在Properties中添加ArriveTime变量

完成后查看运行结果:07:50:00

查看Properties中ArriveTime值为07:50:00

3.”Property Ttransfer”一定要放置Source对应接口下方

八、打开” getDetailInfoByTrainCode”接口,输入TrainCode值${TrainCode},UserID值为空运行接口查看结果;

九、为” getDetailInfoByTrainCode”接口添加断言

1. Declare: //KM[text()='539']/..  点击”Select from current”

2.Declare:

exists(//TrainStation[contains(text(),'${TrainCode}')])

and

exists(//KM[text()='128']/../ArriveTime[text()='${ArriveTime}']) 

Expected Result:true

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值