賽普拉斯斷言文本

密碼空

我需要斷言的錯誤摘要中的這段代碼有問題:

<div id="#prices-form-wizard_es_" class ="errorSummary formSummary" style="display"> == $0
  <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 &amp; Preis</span>
            </div>
...
阿拉潘達斯

你可以試試用id. 由於 id 在網頁上是唯一的,因此在可用時使用 id 總是一個好習慣。

cy.get('#prices-form-wizard_es_').should('include.text', 'Lieferbeginn muss mind. 20 Werktage in der Zukunft liegen')

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章