3 new revisions:
Revision: 71d629b7238e
Branch: default
Author: Robot Framework Developers ([email protected])
Date: Thu Oct 18 02:20:17 2012
Log: XML lib: Documented new keywords....
http://code.google.com/p/robotframework/source/detail?r=71d629b7238e
Revision: 233242e125af
Branch: default
Author: Robot Framework Developers ([email protected])
Date: Thu Oct 18 03:16:33 2012
Log: XMLlib: Fixed Add Element to add a copy of the given element, not
the ...
http://code.google.com/p/robotframework/source/detail?r=233242e125af
Revision: dc4bc5caa45b
Branch: default
Author: Robot Framework Developers ([email protected])
Date: Thu Oct 18 04:23:10 2012
Log: XMLlib: Documented more new keywords....
http://code.google.com/p/robotframework/source/detail?r=dc4bc5caa45b
==============================================================================
Revision: 71d629b7238e
Branch: default
Author: Robot Framework Developers ([email protected])
Date: Thu Oct 18 02:20:17 2012
Log: XML lib: Documented new keywords.
Update issue 1234
Documented the following keywords:
Set Element Tag
Set Element Text
Set Element Attribute
Remove Element Attribute
Remove Element Attributes
http://code.google.com/p/robotframework/source/detail?r=71d629b7238e
Modified:
/src/robot/libraries/XML.py
=======================================
--- /src/robot/libraries/XML.py Thu Oct 18 01:58:11 2012
+++ /src/robot/libraries/XML.py Thu Oct 18 02:20:17 2012
@@ -747,11 +747,44 @@
comparator.compare(self.get_element(source),
self.get_element(expected))
def set_element_tag(self, source, tag, xpath='.'):
+ """Sets the tag of the specified element to `tag`.
+
+ The element whose tag to set is specified using `source` and
+ `xpath`. They have exactly the same semantics as with `Get Element`
+ keyword. The given `source` element is modified and also returned.
+
+ Examples using `${XML}` structure from `Example`:
+ | Set Element Tag | ${XML} | newTag |
+ | Should Be Equal | ${XML.tag} | newTag |
+ | Set Element Tag | ${XML} | xxx |
xpath=second/child |
+ | Element Should Exist | ${XML} | second/xxx |
+ | Element Should Not Exist | ${XML} | second/child |
+
+ New in Robot Framework 2.7.5.
+ """
source = self.get_element(source)
self.get_element(source, xpath).tag = tag
return source
def set_element_text(self, source, text=None, tail=None, xpath='.'):
+ """Sets text and/or tail text of the specified element.
+
+ The element whose text to set is specified using `source` and
+ `xpath`. They have exactly the same semantics as with `Get Element`
+ keyword. The given `source` element is modified and also returned.
+
+ Element's text and tail text are changed only if new `text` and/or
+ `tail` values are given. See `Element attributes` section for more
+ information about text and tail in general.
+
+ Examples using `${XML}` structure from `Example`:
+ | Set Element Text | ${XML} | new text | xpath=first |
+ | Element Text Should Be | ${XML} | new text | xpath=first |
+ | Set Element Text | ${XML} | tail=& | xpath=html/p/b |
+ | Element Text Should Be | ${XML} | Text with bold&italics. |
xpath=html/p | normalize_whitespace=yes |
+
+ New in Robot Framework 2.7.5.
+ """
source = self.get_element(source)
element = self.get_element(source, xpath)
if text is not None:
@@ -761,11 +794,45 @@
return source
def set_element_attribute(self, source, name, value, xpath='.'):
+ """Sets attribute `name` of the specified element to `value`
+
+ The element whose attribute to set is specified using `source` and
+ `xpath`. They have exactly the same semantics as with `Get Element`
+ keyword. The given `source` element is modified and also returned.
+
+ It is possible to both set new attributes and to overwrite
existing.
+ Use `Remove Element Attribute` or `Remove Element Attributes` for
+ removing them.
+
+ Examples using `${XML}` structure from `Example`:
+ | Set Element Attribute | ${XML} | attr | value |
+ | Element Attribute Should Be | ${XML} | attr | value |
+ | Set Element Attribute | ${XML} | id | new |
xpath=first |
+ | Element Attribute Should Be | ${XML} | id | new |
xpath=first |
+
+ New in Robot Framework 2.7.5.
+ """
source = self.get_element(source)
self.get_element(source, xpath).attrib[name] = value
return source
def remove_element_attribute(self, source, name, xpath='.'):
+ """Removes attribute `name` from the specified element.
+
+ The element whose attribute to remove is specified using `source`
and
+ `xpath`. They have exactly the same semantics as with `Get Element`
+ keyword. The given `source` element is modified and also returned.
+
+ It is not a failure to remove a non-existing attribute. Use `Remove
+ Element Attributes` to remove all attributes and `Set Element
Attribute`
+ to set them.
+
+ Examples using `${XML}` structure from `Example`:
+ | Remove Element Attribute | ${XML} | id | xpath=first |
+ | Element Should Not Have Attribute | ${XML} | id | xpath=first |
+
+ New in Robot Framework 2.7.5.
+ """
source = self.get_element(source)
attrib = self.get_element(source, xpath).attrib
if name in attrib:
@@ -773,6 +840,21 @@
return source
def remove_element_attributes(self, source, xpath='.'):
+ """Removes all attributes from the specified element.
+
+ The element whose attributes to remove is specified using `source`
and
+ `xpath`. They have exactly the same semantics as with `Get Element`
+ keyword. The given `source` element is modified and also returned.
+
+ Use `Remove Element Attribute` to remove a single attribute and
+ `Set Element Attribute` to set them.
+
+ Examples using `${XML}` structure from `Example`:
+ | Remove Element Attributes | ${XML} | xpath=first |
+ | Element Should Not Have Attribute | ${XML} | id | xpath=first |
+
+ New in Robot Framework 2.7.5.
+ """
source = self.get_element(source)
self.get_element(source, xpath).attrib.clear()
return source
==============================================================================
Revision: 233242e125af
Branch: default
Author: Robot Framework Developers ([email protected])
Date: Thu Oct 18 03:16:33 2012
Log: XMLlib: Fixed Add Element to add a copy of the given element, not
the original mutable element.
http://code.google.com/p/robotframework/source/detail?r=233242e125af
Modified:
/atest/robot/standard_libraries/xml/add_and_remove_elements.txt
/atest/testdata/standard_libraries/xml/add_and_remove_elements.txt
/src/robot/libraries/XML.py
=======================================
--- /atest/robot/standard_libraries/xml/add_and_remove_elements.txt Wed Oct
17 14:01:06 2012
+++ /atest/robot/standard_libraries/xml/add_and_remove_elements.txt Thu Oct
18 03:16:33 2012
@@ -13,6 +13,9 @@
Add Element With Index
Check Test Case ${TESTNAME}
+
+Added Element Is A Copy
+ Check Test Case ${TESTNAME}
Add Element Returns Root Element
Check Test Case ${TESTNAME}
=======================================
--- /atest/testdata/standard_libraries/xml/add_and_remove_elements.txt Wed
Oct 17 14:01:06 2012
+++ /atest/testdata/standard_libraries/xml/add_and_remove_elements.txt Thu
Oct 18 03:16:33 2012
@@ -24,6 +24,12 @@
${children} = Get Child Elements ${XML}
Should Be Equal ${children[0].tag} new
+Added Element Is A Copy
+ ${elem} = Parse XML ${NEW}
+ Add Element ${XML} ${elem}
+ Clear Element ${elem}
+ Element Attribute Should Be ${XML} attr value xpath=new
+
Add Element Returns Root Element
${root} = Add Element ${SIMPLE} <new>element</new> xpath=c2
Element Text Should Be ${root} element xpath=c2/new
=======================================
--- /src/robot/libraries/XML.py Thu Oct 18 02:20:17 2012
+++ /src/robot/libraries/XML.py Thu Oct 18 03:16:33 2012
@@ -862,7 +862,7 @@
def add_element(self, source, element, index=None, xpath='.'):
source = self.get_element(source)
parent = self.get_element(source, xpath)
- element = self.get_element(element)
+ element = self.copy_element(element)
if index is None:
parent.append(element)
else:
==============================================================================
Revision: dc4bc5caa45b
Branch: default
Author: Robot Framework Developers ([email protected])
Date: Thu Oct 18 04:23:10 2012
Log: XMLlib: Documented more new keywords.
Update issue 1234
Documented:
Add Element
Remove Element
Remove Elements
http://code.google.com/p/robotframework/source/detail?r=dc4bc5caa45b
Modified:
/src/robot/libraries/XML.py
=======================================
--- /src/robot/libraries/XML.py Thu Oct 18 03:16:33 2012
+++ /src/robot/libraries/XML.py Thu Oct 18 04:23:10 2012
@@ -751,7 +751,7 @@
The element whose tag to set is specified using `source` and
`xpath`. They have exactly the same semantics as with `Get Element`
- keyword. The given `source` element is modified and also returned.
+ keyword. The given `source` structure is modified and also
returned.
Examples using `${XML}` structure from `Example`:
| Set Element Tag | ${XML} | newTag |
@@ -771,7 +771,7 @@
The element whose text to set is specified using `source` and
`xpath`. They have exactly the same semantics as with `Get Element`
- keyword. The given `source` element is modified and also returned.
+ keyword. The given `source` structure is modified and also
returned.
Element's text and tail text are changed only if new `text` and/or
`tail` values are given. See `Element attributes` section for more
@@ -798,7 +798,7 @@
The element whose attribute to set is specified using `source` and
`xpath`. They have exactly the same semantics as with `Get Element`
- keyword. The given `source` element is modified and also returned.
+ keyword. The given `source` structure is modified and also
returned.
It is possible to both set new attributes and to overwrite
existing.
Use `Remove Element Attribute` or `Remove Element Attributes` for
@@ -821,7 +821,7 @@
The element whose attribute to remove is specified using `source`
and
`xpath`. They have exactly the same semantics as with `Get Element`
- keyword. The given `source` element is modified and also returned.
+ keyword. The given `source` structure is modified and also
returned.
It is not a failure to remove a non-existing attribute. Use `Remove
Element Attributes` to remove all attributes and `Set Element
Attribute`
@@ -844,7 +844,7 @@
The element whose attributes to remove is specified using `source`
and
`xpath`. They have exactly the same semantics as with `Get Element`
- keyword. The given `source` element is modified and also returned.
+ keyword. The given `source` structure is modified and also
returned.
Use `Remove Element Attribute` to remove a single attribute and
`Set Element Attribute` to set them.
@@ -860,6 +860,33 @@
return source
def add_element(self, source, element, index=None, xpath='.'):
+ """Adds a child element to the specified element.
+
+ The element to whom to add the new element is specified using
`source`
+ and `xpath`. They have exactly the same semantics as with `Get
Element`
+ keyword. The given `source` structure is modified and also
returned.
+
+ The `element` to add can be specified as a path to an XML file or
+ as a string containing XML, or it can be an already parsed XML
element.
+ The element is copied before adding so modifying either the
original
+ or the added element has no effect on the other
+ .
+ The element is added as the last child by default, but a custom
index
+ can be used to alter the position. Indices start from zero (0 =
first
+ position, 1 = second position, etc.), and negative numbers refer to
+ positions at the end (-1 = second last position, -2 = third last,
etc.).
+
+ Examples using `${XML}` structure from `Example`:
+ | Add Element | ${XML} | <new id="x"><c1/></new> |
+ | Add Element | ${XML} | <c2/> | xpath=new |
+ | Add Element | ${XML} | <c3/> | index=1 | xpath=new |
+ | ${new} = | Get Element | ${XML} | new |
+ | Elements Should Be Equal | ${new} | <new
id="x"><c1/><c3/><c2/></new> |
+
+ Use `Remove Element` or `Remove Elements` to remove elements.
+
+ New in Robot Framework 2.7.5.
+ """
source = self.get_element(source)
parent = self.get_element(source, xpath)
element = self.copy_element(element)
@@ -870,12 +897,44 @@
return source
def remove_element(self, source, xpath=''):
+ """Removes the element matching `xpath` from the `source`
structure.
+
+ The element to remove from the `source` is specified with `xpath`
+ using the same semantics as with `Get Element` keyword. The given
+ `source` structure is modified and also returned.
+
+ The keyword fails if `xpath` does not match exactly one element.
+ Use `Remove Elements` to remove all matched elements and `Add
Element`
+ to add new ones.
+
+ Examples using `${XML}` structure from `Example`:
+ | Remove Element | ${XML} | xpath=second |
+ | Element Should Not Exist | ${XML} | xpath=second |
+
+ New in Robot Framework 2.7.5.
+ """
source = self.get_element(source)
self._verify_removing_xpath(xpath)
self._remove_element(source, self.get_element(source, xpath))
return source
def remove_elements(self, source, xpath=''):
+ """Removes all elements matching `xpath` from the `source`
structure.
+
+ The elements to remove from the `source` are specified with `xpath`
+ using the same semantics as with `Get Elements` keyword. The given
+ `source` structure is modified and also returned.
+
+ It is not a failure if `xpath` matches no elements. Use `Remove
Element`
+ to remove exactly one element and `Add Element` to add new ones.
+
+ Examples using `${XML}` structure from `Example`:
+ | Remove Elements | ${XML} | xpath=*/child |
+ | Element Should Not Exist | ${XML} | xpath=second/child |
+ | Element Should Not Exist | ${XML} | xpath=third/child |
+
+ New in Robot Framework 2.7.5.
+ """
source = self.get_element(source)
self._verify_removing_xpath(xpath)
for element in self.get_elements(source, xpath):