This article helps you understand various XML processing and verification commands available in accelQ along with some examples. For various commands in accelQ, XML node is specified in the standard Xpath format.
Note: When working with XML file paths in the following commands, you can specify a relative path to the agent's deployment folder structure or an absolute path on the agent. Here are additional details.
We will use the following sample XML file content for the examples:
breakfast_menu.xml
<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
<food>
<name favorite="true">Belgian Waffles</name>
<price>$5.95</price>
<description>Two of our famous Belgian Waffles </description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>Light Belgian waffles with strawberries</description>
<calories>900</calories>
</food>
<food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>Light Belgian waffles with whipped cream</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description>Made from our homemade sourdough bread</description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>Two eggs, bacon or sausage and hash browns</description>
<calories>950</calories>
</food>
</breakfast_menu>
Reading XML file content
Get XML Node Value
Returns the value of XML node (matching given XPath expression) in the XML content. If the node matching given XPath expression does not exist, then an empty string is returned.
xml content
|
input XML content
|
Get XML Node Value (file)
Returns the value of XML node (matching given XPath expression) in a given XML file. If the node matching given XPath expression does not exist then an empty string is returned.
xml file path
|
input XML file
|
Get XML Node Count
Returns number of XML nodes, in the given XML content, that are matching the given XPath expression.
xml content
|
input XML content
|
Get XML Node Count (file)
Returns number of XML nodes, in the given XML file, that are matching the given XPath expression.
xml content |
input xml content |
Updating XML Content
Add new XML node
Adds new node with the given value at XML node (matching given XPath expression) in the XML content. If the node matching given XPath expression does not exist then an empty string is returned.
xml content
|
input XML content
|
New XML node : food
<food>
<name favorite="true">CHOCOLATE Waffles</name>
<price>$8.95</price>
<description>maple syrup or serve them with chocolate sauce, strawberries, whipped cream and even ice cream</description>
<calories>730</calories>
</food>
Set XML Node value
Updates the value of XML node (matching given XPath expression) in the XML content. If the node matching given XPath expression does not exist then an empty string is returned.
xml content
|
input XML content |
Verify XML nodes
Verify XML Node Exists
Verifies whether the given XML content has a node matching given XPath expression. Note that this is verification command and it fails the test execution if the verification fails.
xml content |
input XML content. |
Verify XML Node Exists (file)
xml content |
input XML content
|
Verify XML Node Not Exists
Verifies whether the given XML content does NOT have a node matching given XPath expression. Note that this is verification command and it fails the test execution if the verification fails.
xml content |
input XML content |
Verify XML Node Not Exists (file)
Verifies whether the given XML file has a node matching given XPath expression. Note that this is verification command and it fails the test execution if the verification fails.
xml content |
input XML content
|
Verify XML Node Value Equals
Verifies whether the XML node (matching given XPath expression) in the XML content has specified value. Note that this is verification command and it fails the test execution if the verification fails.
xml content |
input XML content |
Verify XML Node Value Equals (file)
Verifies whether the XML node (matching given XPath expression) in the XML file has specified value. Note that this is verification command and it fails the test execution if the verification fails.
xml file path |
input XML file path |
Verify XML Node Value Not Equals
Verifies whether the XML node (matching given XPath expression) in the XML content does NOT have specified value. Note that this is verification command and it fails the test execution if the verification fails.
xml content |
input XML content |
Verify XML Node Value Not Equals (file)
Verifies whether the XML node (matching given XPath expression) in the XML file does NOT have specified value. Note that this is verification command and it fails the test execution if the verification fails.
xml file path |
input XML file path |
Verify XML against DTD
We will use the following sample address.xml, address.dtd and address-internal-dtd.xml file contents for the examples:
address.xml
<?xml version = "1.0" encoding = "UTF-8" standalone = "no" ?>
<!DOCTYPE address SYSTEM "C:\\Users\\Tarun\\Desktop\\accelQAgent-jdk8-3.3.0\\agent\\user_data\\address.dtd">
<address>
<name>Employee 1</name>
<company>Accelq</company>
<phone>(011) 123-4567</phone>
</address>
address.dtd
<!ELEMENT address (name,company,phone)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT company (#PCDATA)>
<!ELEMENT phone (#PCDATA)>
address-internal-dtd.xml
<?xml version = "1.0" encoding = "UTF-8" standalone = "yes" ?> <!DOCTYPE address [ <!ELEMENT address (name,company,phone)> <!ELEMENT name (#PCDATA)> <!ELEMENT company (#PCDATA)> <!ELEMENT phone (#PCDATA)> ]> <address> <name>Employee 1</name> <company>Accelq</company> <phone>(011) 123-4567</phone> </address>
Verify XML Against DTD
Validates the XML content against DTD content. Note that this is verification command and it fails the test execution if the verification fails.
xml content |
input XML content |
Verify XML Against DTD (file)
Validates the XML file against DTD file. Note that this is verification command and it fails the test execution if the verification fails.
xml content file |
input XML content file |
Verify XML Against Internal DTD
Validates the XML content against its internal DTD. Note that this is verification command and it fails the test execution if the verification fails.
xml content |
input XML content |
Verify XML Against Internal DTD (file)
Validates the XML file against its internal DTD. Note that this is verification command and it fails the test execution if the verification fails.
xml content file |
input XML content file |
Verify XML against XSD
We will use the following sample contact.xml, contact.xsd file contents for the examples:
contact.xml
<?xml version = "1.0"?>
<contact>
<name>Company 1</name>
<company>Accelq</company>
<phone>0111234567</phone>
</contact>
contact.xsd
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="contact">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="company" type="xs:string"/>
<xs:element name="phone" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Verify XML Against XSD
Validates the XML content against given XSD content. Note that this is verification command and it fails the test execution if the verification fails.
xml content |
input XML content |
Verify XML Against XSD (file)
Validates the XML file against given XSD file. Note that this is verification command and it fails the test execution if the verification fails.
xml content file |
input XML content file |
Comparing XML content
Compare XML Content
xml content1
|
input XML content
|
Compare XML Files
Verifies whether the content in one XML file is same as that of another XML file. Note that this is verification command and it fails the test execution if the verification fails.
xml file path1 |
input XML file
|
Compare Node In XML Files
Verifies whether the XML node (matching given XPath expression) value in the XML content is same as that of specified XML content. Note that this is verification command and it fails the test execution if the verification fails.
xml content1
|
input XML content
|
Compare Node In XML Files (file)
Verifies whether the XML node (matching given XPath expression) value in the XML file is same as that of specified XML file. Note that this is verification command and it fails the test execution if the verification fails.
xml content file1
|
input XML content file1
|
Comments
0 comments
Please sign in to leave a comment.