mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-30 10:56:09 +03:00
50 lines
6.2 KiB
HTML
50 lines
6.2 KiB
HTML
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/assert-xpath</span></span>
|
|
</span><span class="response"><span class="line"></span>
|
|
<span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
|
|
<span class="line section-header">[Asserts]</span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"normalize-space(//data)"</span> <span class="predicate-type">==</span> <span class="string">"café"</span></span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"normalize-space(//data)"</span> <span class="predicate-type">==</span> <span class="string">"caf\u{00e9}"</span></span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"//toto"</span> <span class="not">not</span> <span class="predicate-type">exists</span></span>
|
|
<span class="line"></span>
|
|
<span class="xml"><span class="line"><data>café</data></span></span>
|
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
|
<span class="line"></span>
|
|
<span class="line"></span><span class="comment"># Test XPath assert with XML namespace.</span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/assert-xpath-simple-namespaces</span></span>
|
|
</span><span class="response"><span class="line"></span>
|
|
<span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
|
|
<span class="line section-header">[Asserts]</span>
|
|
<span class="line"></span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"string(//bk:book/bk:title)"</span> <span class="predicate-type">==</span> <span class="string">"Cheaper by the Dozen"</span></span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"string(//*[name()='bk:book']/*[name()='bk:title'])"</span> <span class="predicate-type">==</span> <span class="string">"Cheaper by the Dozen"</span></span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"string(//*[local-name()='book']/*[local-name()='title'])"</span> <span class="predicate-type">==</span> <span class="string">"Cheaper by the Dozen"</span></span>
|
|
<span class="line"></span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"string(//bk:book/isbn:number)"</span> <span class="predicate-type">==</span> <span class="string">"1568491379"</span></span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"string(//*[name()='bk:book']/*[name()='isbn:number'])"</span> <span class="predicate-type">==</span> <span class="string">"1568491379"</span></span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"string(//*[local-name()='book']/*[local-name()='number'])"</span> <span class="predicate-type">==</span> <span class="string">"1568491379"</span></span>
|
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
|
<span class="line"></span>
|
|
<span class="line"></span><span class="comment"># Test XPath assert with default XML namespace.</span>
|
|
<span class="line"></span><span class="comment"># _ can be used to target a default namespace.</span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/assert-xpath-svg</span></span>
|
|
</span><span class="response"><span class="line"></span>
|
|
<span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
|
|
<span class="line section-header">[Asserts]</span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"//_:svg/_:g/_:circle"</span> <span class="subquery-type">count</span> <span class="predicate-type">==</span> <span class="number">3</span></span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"//*[local-name()='svg']/*[local-name()='g']/*[local-name()='circle']"</span> <span class="subquery-type">count</span> <span class="predicate-type">==</span> <span class="number">3</span></span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"//*[name()='svg']/*[name()='g']/*[name()='circle']"</span> <span class="subquery-type">count</span> <span class="predicate-type">==</span> <span class="number">3</span></span>
|
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
|
<span class="line"></span>
|
|
<span class="line"></span><span class="comment"># Test XPath assert with default and prefixed XML namespace.</span>
|
|
<span class="line"></span><span class="comment"># _ can be used to target a default namespace.</span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/assert-xpath-namespaces</span></span>
|
|
</span><span class="response"><span class="line"></span>
|
|
<span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
|
|
<span class="line section-header">[Asserts]</span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"string(//_:book/_:title)"</span> <span class="predicate-type">==</span> <span class="string">"Cheaper by the Dozen"</span></span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"string(//_:book/isbn:number)"</span> <span class="predicate-type">==</span> <span class="string">"1568491379"</span></span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"//*[name()='book']/*[name()='notes']"</span> <span class="subquery-type">count</span> <span class="predicate-type">==</span> <span class="number">1</span></span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"//*[local-name()='book']/*[local-name()='notes']"</span> <span class="subquery-type">count</span> <span class="predicate-type">==</span> <span class="number">1</span></span>
|
|
<span class="line"><span class="query-type">xpath</span> <span class="string">"//_:book/_:notes/*[local-name()='p']"</span> <span class="subquery-type">count</span> <span class="predicate-type">==</span> <span class="number">1</span></span>
|
|
</span></span><span class="line"></span>
|
|
</code></pre> |