如何在机器人框架中更新xml元素文本?

时间:2019-05-20 07:59:32

标签: xml xml-parsing robotframework xmlupdate

对于自动化,我需要添加无效案例。有效载荷是XML。我考虑过更新现有的XML有效负载元素文本,而不是为无效情况添加新的XML。

XML Example:
<?xml version="1.0" encoding="UTF-8"?>
<note>
  <to>Tove</to>
  <from>Jani</from>
<content>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</content>
</note>
          [Documentation]
          [Tags]  API  Regression  POST
#          Arrange
          create session  alias  ${url}
          ${headers}  create dictionary  Content-Type=application/xml

          ${root}  Parse xml  ${xml_path}

#          ${cCode}  get element text  ${root}  ./content/heading
#          log to console  before update the value is "${cCode}"

          ${updated_xml}  Set element text  ${root}  abc  xpath=./content/heading


#          ${cCode}  get element text  ${root}  ./content/heading
#          log to console  after update the value is "${cCode}"

#          Act
          ${resp}=  Post Request  alias  resource_uri  data="${updated_xml}"  headers=${headers}

#          Assert
          Should Be Equal As Strings  ${resp.status_code}  200
          should contain  ${resp.content}  hasError="true" ```

Is this the way to do the scripting of updating element text.
Please guide me to make this working.

0 个答案:

没有答案