hurl/integration/tests_ok/assert_xpath.html

53 lines
6.6 KiB
HTML
Raw Normal View History

2021-09-21 07:36:53 +03:00
<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>
2022-11-11 16:25:00 +03:00
<span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
2023-04-11 18:28:28 +03:00
<span class="line"><span class="section-header">[Asserts]</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é"</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>
2022-09-09 17:54:28 +03:00
<span class="line"><span class="query-type">xpath</span> <span class="string">"normalize-space(//data)"</span> <span class="predicate-type">&gt;</span> <span class="string">"CAFÉ"</span></span>
2021-09-21 07:36:53 +03:00
<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">&lt;data&gt;café&lt;/data&gt;</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>
2022-11-11 16:25:00 +03:00
<span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
2023-04-11 18:28:28 +03:00
<span class="line"><span class="section-header">[Asserts]</span></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>
2022-11-11 16:25:00 +03:00
<span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
2023-04-11 18:28:28 +03:00
<span class="line"><span class="section-header">[Asserts]</span></span>
2022-10-25 09:59:18 +03:00
<span class="line"><span class="query-type">xpath</span> <span class="string">"//_:svg/_:g/_:circle"</span> <span class="filter-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="filter-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="filter-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>
2022-11-11 16:25:00 +03:00
<span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
2023-04-11 18:28:28 +03:00
<span class="line"><span class="section-header">[Asserts]</span></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>
2022-09-09 17:54:28 +03:00
<span class="line"><span class="query-type">xpath</span> <span class="string">"string(//_:book/_:title)"</span> <span class="predicate-type">&gt;</span> <span class="string">"Cheaper"</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>
2022-10-25 09:59:18 +03:00
<span class="line"><span class="query-type">xpath</span> <span class="string">"//*[name()='book']/*[name()='notes']"</span> <span class="filter-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="filter-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="filter-type">count</span> <span class="predicate-type">==</span> <span class="number">1</span></span>
</span></span><span class="line"></span>
</code></pre>