[英]XML parser is not working in robot framework
我正在使用xml解析器从响应中访问元素,这里是代码
# define library
*** Settings ***
Library SudsLibrary
Library XML
Library Collections
*** Variables ***
*** Test Cases ***
test
abc
*** Keywords ***
# create soap client object
Create Soap Client http://www.webservicex.com/globalweather.asmx?wsdl
${GetCitiesByCountry} Create Wsdl Object GetCitiesByCountry
${GetCitiesByCountry.CountryName} Set Variable india
# call soap web service
call soap method GetCitiesByCountry ${GetCitiesByCountry}
log ${GetCitiesByCountry}
${soap_response} Get Last Received
Log ${soap_response}
${root}= parse xml ${soap_response}
log ${root}
${root1}= parse xml ${soap_response} first
log ${root1}
输出为:它不显示生成的xml
Documentation:
Logs the given message with the given level.
Start / End / Elapsed: 20170626 11:52:46.886 / 20170626 11:52:46.886 / 00:00:00.000
11:52:46.886 INFO <Element 'Envelope' at 0x0000000003670930
BuiltIn . Log ${root1}
Documentation:
Logs the given message with the given level.
Start / End / Elapsed: 20170626 11:52:46.887 / 20170626 11:52:46.887 / 00:00:00.000
11:52:46.887 INFO <Element '{http://schemas.xmlsoap.org/soap/envelope/}Envelope' at 0x0000000003728C60>
在Web服务的响应中,发生了一些奇怪的事情。 似乎其中一部分是HTML编码的,而另一部分则不是。 无法解释这一点,但是通过简单的字符串替换就可以轻松解决。
*** Settings ***
Library SudsLibrary
Library XML
Library String
*** Test Cases ***
Test Webservice
# create soap client object
Create Soap Client http://www.webservicex.com/globalweather.asmx?wsdl
${GetCitiesByCountry} Create Wsdl Object GetCitiesByCountry
${GetCitiesByCountry.CountryName} Set Variable india
# # call soap web service
call soap method GetCitiesByCountry ${GetCitiesByCountry}
${soap_response} Get Last Received
# Clean up response
${soap_response} Replace String ${soap_response} < <
${soap_response} Replace String ${soap_response} > >
${node}= Get Element Text ${soap_response} .//Table[1]//Country[1]
Log To Console ${node}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.