3 new revisions:
Revision: 3373a0ca7eb0
Author: Pekka Klärck
Date: Thu Jul 5 04:48:26 2012
Log: XML lib: Implemented, and tested, Get Child Elements keyword.
http://code.google.com/p/robotframework/source/detail?r=3373a0ca7eb0
Revision: d0ebbc49b2fb
Author: Pekka Klärck
Date: Thu Jul 5 05:03:56 2012
Log: XML lib: Test that xpath parent/child matches all child tags
under all...
http://code.google.com/p/robotframework/source/detail?r=d0ebbc49b2fb
Revision: df63fdb9e6e9
Author: Pekka Klärck
Date: Thu Jul 5 05:51:05 2012
Log: XML lib: more thorough testing of // in xpath
http://code.google.com/p/robotframework/source/detail?r=df63fdb9e6e9
==============================================================================
Revision: 3373a0ca7eb0
Author: Pekka Klärck
Date: Thu Jul 5 04:48:26 2012
Log: XML lib: Implemented, and tested, Get Child Elements keyword.
http://code.google.com/p/robotframework/source/detail?r=3373a0ca7eb0
Modified:
/atest/robot/standard_libraries/xml/get_elements.txt
/atest/testdata/standard_libraries/xml/get_elements.txt
/src/robot/libraries/XML.py
=======================================
--- /atest/robot/standard_libraries/xml/get_elements.txt Tue Jul 3
05:17:13 2012
+++ /atest/robot/standard_libraries/xml/get_elements.txt Thu Jul 5
04:48:26 2012
@@ -25,6 +25,15 @@
Get elements returns empty list when no elements match
Check Test Case ${TESTNAME}
+
+Get child elements
+ Check Test Case ${TESTNAME}
+
+Get child elements fails when multiple parent elements match
+ Check Test Case ${TESTNAME}
+
+Get child elements fails when no parent element matches
+ Check Test Case ${TESTNAME}
Non-ASCII
Check Test Case ${TESTNAME}
=======================================
--- /atest/testdata/standard_libraries/xml/get_elements.txt Sun Jul 1
15:36:45 2012
+++ /atest/testdata/standard_libraries/xml/get_elements.txt Thu Jul 5
04:48:26 2012
@@ -28,13 +28,31 @@
Get Element ${TEST} non-existing
Get elements
- ${children}= Get Elements ${TEST} child
- Length Should Be ${children} 3
- Should Be Equal ${children[0].text} child 1 text
+ ${elements}= Get Elements ${TEST} child
+ Length Should Be ${elements} 3
+ Should Be Equal ${elements[0].text} child 1 text
Get elements returns empty list when no elements match
- ${children}= Get Elements ${TEST} non-existing
- Length Should Be ${children} 0
+ ${elements}= Get Elements ${TEST} non-existing
+ Should Be Empty ${elements}
+
+Get child elements
+ ${children}= Get Child Elements ${TEST}
+ Length Should Be ${children} 4
+ Should Be Equal ${children[0].text} child 1 text
+ Should Be Equal ${children[1].attrib['id']} 2
+ Should Be Equal ${children[2].attrib['id']} 3
+ Should Be Equal ${children[3].tag} another
+ ${children}= Get Child Elements ${TEST} another/child
+ Should Be Empty ${children}
+
+Get child elements fails when multiple parent elements match
+ [Documentation] FAIL Multiple elements (3) matching 'child' found.
+ Get Child Elements ${TEST} child
+
+Get child elements fails when no parent element matches
+ [Documentation] FAIL No element matching 'non-existing' found.
+ Get Child Elements ${TEST} non-existing
Non-ASCII
${elem}= Get Element <root><täg/></root> täg
=======================================
--- /src/robot/libraries/XML.py Tue Jul 3 13:01:19 2012
+++ /src/robot/libraries/XML.py Thu Jul 5 04:48:26 2012
@@ -73,6 +73,9 @@
'results manually and consider upgrading
to 2.7.')
return xpath
+ def get_child_elements(self, source, xpath='.'):
+ return list(self.get_element(source, xpath))
+
def get_element_text(self, source, xpath='.',
normalize_whitespace=False):
element = self.get_element(source, xpath)
text = ''.join(self._yield_texts(element))
==============================================================================
Revision: d0ebbc49b2fb
Author: Pekka Klärck
Date: Thu Jul 5 05:03:56 2012
Log: XML lib: Test that xpath parent/child matches all child tags
under all parents
http://code.google.com/p/robotframework/source/detail?r=d0ebbc49b2fb
Modified:
/atest/robot/standard_libraries/xml/xpath.txt
/atest/testdata/standard_libraries/xml/get_elements.txt
/atest/testdata/standard_libraries/xml/test.xml
/atest/testdata/standard_libraries/xml/xpath.txt
=======================================
--- /atest/robot/standard_libraries/xml/xpath.txt Tue Jul 3 13:01:19 2012
+++ /atest/robot/standard_libraries/xml/xpath.txt Thu Jul 5 05:03:56 2012
@@ -11,6 +11,9 @@
Path
Check Test Case ${TESTNAME}
+
+Path matches children from different parents
+ Check Test Case ${TESTNAME}
'*'
Check Test Case ${TESTNAME}
=======================================
--- /atest/testdata/standard_libraries/xml/get_elements.txt Thu Jul 5
04:48:26 2012
+++ /atest/testdata/standard_libraries/xml/get_elements.txt Thu Jul 5
05:03:56 2012
@@ -12,8 +12,8 @@
Get element from xml file
${child}= Get Element ${TEST} another
Should Be Equal ${child.tag} another
- ${child}= Get Element ${TEST} child/grandchild
- Should Be Equal ${child.text} grand child text
+ ${child}= Get Element ${TEST} another/child
+ Should Be Equal ${child.text} text
Get element from xml string
${child}= Get Element <root><tag>text</tag></root> tag
=======================================
--- /atest/testdata/standard_libraries/xml/test.xml Fri Jun 29 01:26:08 2012
+++ /atest/testdata/standard_libraries/xml/test.xml Thu Jul 5 05:03:56 2012
@@ -6,7 +6,7 @@
<grandchild>grand child text</grandchild>
more text
</child>
- <child id="3" a2="xxx" a3="y"/>
+ <child id="3" a2="xxx" a3="y"><grandchild><ggc/></grandchild></child>
<another attr="value">
<child>text</child>
</another>
=======================================
--- /atest/testdata/standard_libraries/xml/xpath.txt Tue Jul 3 13:01:19
2012
+++ /atest/testdata/standard_libraries/xml/xpath.txt Thu Jul 5 05:03:56
2012
@@ -15,16 +15,24 @@
Path
another/child child text
+
+Path matches children from different parents
+ [Template] NONE
+ @{elements}= Get Elements ${TEST} child/grandchild
+ Length Should Be ${elements} 2
+ :FOR ${elem} IN @{elements}
+ \ Should Be Equal ${elem.tag} grandchild
+ Should Be Equal ${elem.text} ${NONE}
'*'
- */grandchild grandchild grand child text
+ */child child text
'.'
. test
./another another
'//'
- .//grandchild grandchild
+ .//ggc ggc
'//' returning multiple elements
[Template] NONE
==============================================================================
Revision: df63fdb9e6e9
Author: Pekka Klärck
Date: Thu Jul 5 05:51:05 2012
Log: XML lib: more thorough testing of // in xpath
http://code.google.com/p/robotframework/source/detail?r=df63fdb9e6e9
Modified:
/atest/testdata/standard_libraries/xml/xpath.txt
=======================================
--- /atest/testdata/standard_libraries/xml/xpath.txt Thu Jul 5 05:03:56
2012
+++ /atest/testdata/standard_libraries/xml/xpath.txt Thu Jul 5 05:51:05
2012
@@ -33,6 +33,9 @@
'//'
.//ggc ggc
+ .//grandchild/ggc ggc
+ child//ggc ggc
+ another//child child
'//' returning multiple elements
[Template] NONE