Как обновить текст элемента xml в фреймворке робота?

Для автоматизации мне нужно добавить неверные случаи. Полезная нагрузка была из 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 ответов

Другие вопросы по тегам