下面是 XML 檔案內容:
<?xml version="1.0" encoding="UTF-8"?>
<reports>
<!--
===================
Title
===================
-->
<report landingPageWidgetType="SECTION_CONTROLLER"
width="3"
title="Marketing"
showTimespanFilter="true"
backgroundColor="#0F8287">
</report>
<!--
===================
1st row
===================
-->
<report reportQueryType="GENERAL_COUNTS"
landingPageWidgetType="COUNTER_REPORT"
generalCountsCounters="TOTAL_USERS,ACTIVE_USERS,NEW_USERS,SESSIONS"
timeType="LAST_MONTH"
width="3"
title="Users"
reportType="STATIC"
chartType="COUNTERS">
<Parameters>
<Conditions>
<Condition type="USERS_REPORTED">true</Condition>
</Conditions>
</Parameters>
</report>
<report reportQueryType="GENERAL_COUNTS"
landingPageWidgetType="COUNTER_REPORT"
generalCountsCounters="TOTAL_ENDPOINTS,ACTIVE_ENDPOINTS,NEW_ENDPOINTS,SESSIONS"
timeType="LAST_MONTH"
width="3"
title="Endpoints"
reportType="STATIC"
chartType="COUNTERS">
<Parameters>
<Conditions>
<Condition type="USERS_REPORTED">false</Condition>
<Condition type="SINGLE_ENDPOINT">false</Condition>
</Conditions>
</Parameters>
</report>
<!--
===================
2nd row
===================
-->
<report reportQueryType="GEOGRAPHIC_USERS"
landingPageWidgetType="STANDARD_REPORT"
timeType="LAST_12_MONTHS"
width="2"
title="Usage Map: Users"
reportType="MAP"
xAxisTitle="Country"
yAxisTitle="# of Users">
<Parameters>
<Conditions>
<Condition type="USERS_REPORTED">true</Condition>
<Condition type="CUSTOMERS_REPORTED">true</Condition>
</Conditions>
</Parameters>
</report>
<report reportQueryType="GEOGRAPHIC_USERS"
landingPageWidgetType="STANDARD_REPORT"
timeType="LAST_12_MONTHS"
width="3"
title="Usage Map: Users"
reportType="MAP"
xAxisTitle="Country"
yAxisTitle="# of Users">
<Parameters>
<Conditions>
<Condition type="USERS_REPORTED">true</Condition>
<Condition type="CUSTOMERS_REPORTED">false</Condition>
</Conditions>
</Parameters>
</report>
我正在嘗試獲取每個報告下的標題并檢查是否存在條件,顯示條件的型別及其值。
我嘗試了以下方法:
${xml_obj}= Parse XML ${xmlFile}
${title}= Get Element Text ${xml_obj} @title
Log To Console ${title}
//沒有顯示任何內容并且 RIDE 無法識別 @ 符號。
此外,創建了一個 for 回圈來查找條件:
@{reports}= Get Elements ${xml_obj} .//report//Conditions
${elemList}= Get elements ${reports}[0] *
@{elemList}= Convert To List ${elemList}
Log To Console ${elemList} // also it was shown empty.
FOR ${var} IN @{elemList}
@{report_title}= Get Elements Texts ${var} title
Log To Console ${report_title}
END
我是 RFW 的新手,我被要求創建一個測驗套件,該套件從 XML 中提取資料,然后將其與網頁資料進行比較。
任何人都可以指導我采用更好的方法嗎?
謝謝,
uj5u.com熱心網友回復:
您不能使用 Get Element 文本來獲取標題,因為標題是一個屬性。此代碼決議報告中的標題,應該可以幫助您入門:
*** Settings ***
Library XML
*** Variables ***
${xmlFile} MyXMLFile.xml
*** Test Cases ***
Parse title
${xml_obj}= Parse XML ${xmlFile}
@{elements}= Get Elements ${xml_obj} report
FOR ${element} IN @{elements}
${title}= Get Element Attribute ${element} title
Log To Console ${title}
END
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/359603.html
上一篇:操作欄內容沒有隱藏
下一篇:解組回傳重復的空值
