赛普拉斯断言文本
Cypress assert text
我需要断言的错误摘要中的这段代码有问题:
<div id="#prices-form-wizard_es_" class ="errorSummary formSummary" style="display"> == [=10=]
<ul>
<li>
::marker
Lieferbeginn muss mind. 20 Werktage in der Zukunft liegen
</li>
当我尝试使用此代码断言此文本时:
cy.get('.errorSummary > ul > li').eq(0)
.should('have.text', 'Lieferbeginn muss mind. 20 Werktage in der Zukunft liegen')
我收到错误消息:
AssertionError
Timed out retrying after 20000ms:
expected '<li>' to have text 'Lieferbeginn muss mind. 20 Werktage in der Zukunft liegen',
but the text was 'dummy'
我想 ::marker
条目导致了这里的问题,但我不知道这个问题的解决方法。
完成HTML:
<form novalidate="novalidate" id="prices-form-wizard" action="test" method="post" data-dashlane-rid="86657b96f87d2628" style="position: relative;" data-form-type="other">
<input type="hidden" value="VEpQdDJCdE5uRDNBY2dCbE9tb1d0aE5FVEJlbUtJZjTHM5EBAf5bb250N_5-qprVWUq4nbUElJO1EnMXhm39hA==" name="YII_CSRF_TOKEN"><div class="successSummary form-submit-summary" style="display: none;">
<p>Änderungen gespeichert</p>
<a href="javascript:void(0)" class="summaryClose" onclick="$(this).closest('.successSummary').slideUp();return false;"><svg class="svg-inline--fa fa-times-circle fa-w-16" aria-hidden="true" focusable="false" data-prefix="fad" data-icon="times-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><g class="fa-group"><path class="fa-secondary" fill="currentColor" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1a12 12 0 0 1 0 17L338 377.6a12 12 0 0 1-17 0L256 312l-65.1 65.6a12 12 0 0 1-17 0L134.4 338a12 12 0 0 1 0-17l65.6-65-65.6-65.1a12 12 0 0 1 0-17l39.6-39.6a12 12 0 0 1 17 0l65 65.7 65.1-65.6a12 12 0 0 1 17 0l39.6 39.6a12 12 0 0 1 0 17L312 256z"></path><path class="fa-primary" fill="currentColor" d="M377.6 321.1a12 12 0 0 1 0 17L338 377.6a12 12 0 0 1-17 0L256 312l-65.1 65.6a12 12 0 0 1-17 0L134.4 338a12 12 0 0 1 0-17l65.6-65-65.6-65.1a12 12 0 0 1 0-17l39.6-39.6a12 12 0 0 1 17 0l65 65.7 65.1-65.6a12 12 0 0 1 17 0l39.6 39.6a12 12 0 0 1 0 17L312 256z"></path></g></svg><!-- <i class="fad fa-times-circle"></i> --></a>
</div><div id="prices-form-wizard_es_" class="errorSummary formSummary" style="display: flow-root;"><a href="javascript:void(0)" class="summaryClose" onclick="$('#prices-form-wizard_es_').slideUp();return false;">
<svg class="svg-inline--fa fa-times-circle fa-w-16" aria-hidden="true" focusable="false" data-prefix="fad" data-icon="times-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><g class="fa-group"><path class="fa-secondary" fill="currentColor" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1a12 12 0 0 1 0 17L338 377.6a12 12 0 0 1-17 0L256 312l-65.1 65.6a12 12 0 0 1-17 0L134.4 338a12 12 0 0 1 0-17l65.6-65-65.6-65.1a12 12 0 0 1 0-17l39.6-39.6a12 12 0 0 1 17 0l65 65.7 65.1-65.6a12 12 0 0 1 17 0l39.6 39.6a12 12 0 0 1 0 17L312 256z"></path><path class="fa-primary" fill="currentColor" d="M377.6 321.1a12 12 0 0 1 0 17L338 377.6a12 12 0 0 1-17 0L256 312l-65.1 65.6a12 12 0 0 1-17 0L134.4 338a12 12 0 0 1 0-17l65.6-65-65.6-65.1a12 12 0 0 1 0-17l39.6-39.6a12 12 0 0 1 17 0l65 65.7 65.1-65.6a12 12 0 0 1 17 0l39.6 39.6a12 12 0 0 1 0 17L312 256z"></path></g></svg><!-- <i class="fad fa-times-circle"></i> --></a>
<ul><li>Lieferbeginn muss mind. 20 Werktage in der Zukunft liegen</li><li>Lieferende muss ausgefüllt sein, um Preise für diesen Tarif abzufragen</li></ul></div><input name="PricesWizardForm[tariff_type]" id="PricesWizardForm_tariff_type" type="hidden" value="1">
<div class="form-section multi-flex">
<div class="section-part">
<div class="portlet-separator">
<span>Produkt & Preis</span>
</div>
...
你可以试试 id
。由于 ID 在网页上是唯一的,因此最好使用可用的 ID。
cy.get('#prices-form-wizard_es_').should('include.text', 'Lieferbeginn muss mind. 20 Werktage in der Zukunft liegen')
我需要断言的错误摘要中的这段代码有问题:
<div id="#prices-form-wizard_es_" class ="errorSummary formSummary" style="display"> == [=10=]
<ul>
<li>
::marker
Lieferbeginn muss mind. 20 Werktage in der Zukunft liegen
</li>
当我尝试使用此代码断言此文本时:
cy.get('.errorSummary > ul > li').eq(0)
.should('have.text', 'Lieferbeginn muss mind. 20 Werktage in der Zukunft liegen')
我收到错误消息:
AssertionError
Timed out retrying after 20000ms:
expected '<li>' to have text 'Lieferbeginn muss mind. 20 Werktage in der Zukunft liegen',
but the text was 'dummy'
我想 ::marker
条目导致了这里的问题,但我不知道这个问题的解决方法。
完成HTML:
<form novalidate="novalidate" id="prices-form-wizard" action="test" method="post" data-dashlane-rid="86657b96f87d2628" style="position: relative;" data-form-type="other">
<input type="hidden" value="VEpQdDJCdE5uRDNBY2dCbE9tb1d0aE5FVEJlbUtJZjTHM5EBAf5bb250N_5-qprVWUq4nbUElJO1EnMXhm39hA==" name="YII_CSRF_TOKEN"><div class="successSummary form-submit-summary" style="display: none;">
<p>Änderungen gespeichert</p>
<a href="javascript:void(0)" class="summaryClose" onclick="$(this).closest('.successSummary').slideUp();return false;"><svg class="svg-inline--fa fa-times-circle fa-w-16" aria-hidden="true" focusable="false" data-prefix="fad" data-icon="times-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><g class="fa-group"><path class="fa-secondary" fill="currentColor" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1a12 12 0 0 1 0 17L338 377.6a12 12 0 0 1-17 0L256 312l-65.1 65.6a12 12 0 0 1-17 0L134.4 338a12 12 0 0 1 0-17l65.6-65-65.6-65.1a12 12 0 0 1 0-17l39.6-39.6a12 12 0 0 1 17 0l65 65.7 65.1-65.6a12 12 0 0 1 17 0l39.6 39.6a12 12 0 0 1 0 17L312 256z"></path><path class="fa-primary" fill="currentColor" d="M377.6 321.1a12 12 0 0 1 0 17L338 377.6a12 12 0 0 1-17 0L256 312l-65.1 65.6a12 12 0 0 1-17 0L134.4 338a12 12 0 0 1 0-17l65.6-65-65.6-65.1a12 12 0 0 1 0-17l39.6-39.6a12 12 0 0 1 17 0l65 65.7 65.1-65.6a12 12 0 0 1 17 0l39.6 39.6a12 12 0 0 1 0 17L312 256z"></path></g></svg><!-- <i class="fad fa-times-circle"></i> --></a>
</div><div id="prices-form-wizard_es_" class="errorSummary formSummary" style="display: flow-root;"><a href="javascript:void(0)" class="summaryClose" onclick="$('#prices-form-wizard_es_').slideUp();return false;">
<svg class="svg-inline--fa fa-times-circle fa-w-16" aria-hidden="true" focusable="false" data-prefix="fad" data-icon="times-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><g class="fa-group"><path class="fa-secondary" fill="currentColor" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1a12 12 0 0 1 0 17L338 377.6a12 12 0 0 1-17 0L256 312l-65.1 65.6a12 12 0 0 1-17 0L134.4 338a12 12 0 0 1 0-17l65.6-65-65.6-65.1a12 12 0 0 1 0-17l39.6-39.6a12 12 0 0 1 17 0l65 65.7 65.1-65.6a12 12 0 0 1 17 0l39.6 39.6a12 12 0 0 1 0 17L312 256z"></path><path class="fa-primary" fill="currentColor" d="M377.6 321.1a12 12 0 0 1 0 17L338 377.6a12 12 0 0 1-17 0L256 312l-65.1 65.6a12 12 0 0 1-17 0L134.4 338a12 12 0 0 1 0-17l65.6-65-65.6-65.1a12 12 0 0 1 0-17l39.6-39.6a12 12 0 0 1 17 0l65 65.7 65.1-65.6a12 12 0 0 1 17 0l39.6 39.6a12 12 0 0 1 0 17L312 256z"></path></g></svg><!-- <i class="fad fa-times-circle"></i> --></a>
<ul><li>Lieferbeginn muss mind. 20 Werktage in der Zukunft liegen</li><li>Lieferende muss ausgefüllt sein, um Preise für diesen Tarif abzufragen</li></ul></div><input name="PricesWizardForm[tariff_type]" id="PricesWizardForm_tariff_type" type="hidden" value="1">
<div class="form-section multi-flex">
<div class="section-part">
<div class="portlet-separator">
<span>Produkt & Preis</span>
</div>
...
你可以试试 id
。由于 ID 在网页上是唯一的,因此最好使用可用的 ID。
cy.get('#prices-form-wizard_es_').should('include.text', 'Lieferbeginn muss mind. 20 Werktage in der Zukunft liegen')