Robot Framework中的SudsLibrary:获取和设置对象属性

时间:2019-02-08 17:21:52

标签: soap robotframework suds

我正在使用SudsLibrary for Robot Framework。以下是我正在测试的Web服务的Rq / Rs。您还将找到Robot Framework信息以及我对发生的事情的评论。

请求

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sec="http://localhost/ABC/Services/Security/">
   <soapenv:Header/>
   <soapenv:Body>
      <sec:AuthUser>
         <sec:userName>MyAdmin</sec:userName>
         <sec:password>Password123</sec:password>
      </sec:AuthUser>
   </soapenv:Body>
</soapenv:Envelope>

响应

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.ompum-open.org/wss/2004/01/ompum-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.ompum-open.org/wss/2004/01/ompum-200401-wss-wssecurity-utility-1.0.xsd">
   <soap:Header>
      ...
   </soap:Header>
   <soap:Body>
      <AuthUserResponse xmlns="http://localhost/ABC/Services/Security/">
         <AuthTicket>k3l5d9k6-3z53-8765-b512-df09as87</AuthTicket>
      </AuthUserResponse>
   </soap:Body>
</soap:Envelope>
*** Settings ***
Library  SudsLibrary

*** Test Case ***
Check App Auth Ticket
    Create Soap Client    http://localhost/Services/Authentication.asmx?wsdl
    ${WSDLobj}    Create Wsdl Object    AuthUser
    Set Wsdl Object Attribute    ${WSDLobj}    userName    MyAdmin
    Set Wsdl Object Attribute    ${WSDLobj}    password    Password123
    ${result}    Call Soap Method    AuthUser    ${WSDLobj}
    log    Result: ${result}
    # Now get the specific element from the response
    ${AuthVal}    Get Wsdl Object Attribute    ${result}    AuthTicket
    log    Auth Ticket: ${AuthVal}

在我的测试用例Check App Auth Ticket中,一切都成功了,直到我调用SudsLibrary Get Wsdl Object Attribute关键字为止。发生以下错误:ValueError: Object must be a WSDL object (suds.sudsobject.Object)。为什么创建对象并成功调用该对象时会出现错误?

当我打印出${result}变量时,它是AuthVal的值。但是,我想从Web服务响应中显式提取特定的值/元素。我还有其他Web服务响应,需要我解析这些数据以进行端到端测试。

0 个答案:

没有答案