標籤:
LR在WebService虛擬使用者協議中支援兩種方式測試WebService,一種是通過“Add Service Call”的方式,一種是Import SOAP的方式。
Import SOAP的方式需要匯入定義好的XML請求檔案。
取到WebService返回的XML資料後,可以使用XPath的方式驗證資料,LR提供了幾個處理XML的函數:
lr_xml_get_values() //Retrieves values of XML elements found by a query
lr_xml_set_values() //Sets the values of XML elements found by a query
lr_xml_extract() //Extracts XML string fragments from an XML string
lr_xml_delete() //Deletes fragments from an XML string
lr_xml_replace() //Replaces fragments of an XML string
lr_xml_insert() //Inserts a new XML fragment into an XML string
lr_xml_find() //Verifies that XML values are returned by a query
lr_xml_transform() //Applies Extensible Stylesheet Language (XSL) Transformation to XML data
實際上,使用LR還有一種測試WebService的方式,就是採用HTTP協議,因為WebService是構建在HTTP協議之上的,因此可以WEB虛擬使用者協議中的web_custom_request來構造WebService的請求。
學習LR測試WebService時,如果沒有現成的WebService,又懶得寫或不會寫,可以用Parasoft網站的WSDL來實驗:
http://soatest.parasoft.com/store-01.wsdl
參考:
http://blog.testsautomation.com/2009/07/web-services-testing-in-loadrunner/
http://blog.testsautomation.com/2009/05/validating-web-service-response-with-xpath/
http://blog.testsautomation.com/2009/01/web-services-performance-using-loadrunner/
LoadRunner測試WebService的3種方式