赛普拉斯:处理动态下拉列表以避免“ TypeError:无法读取未定义的属性'selectize'”

时间:2019-07-22 04:34:38

标签: javascript cypress

我想知道如何使用cypress从动态下拉菜单中选择一个选项。我尝试了几种配置,但始终收到错误“ TypeError:无法读取未定义的属性'selectize'”

元素定义如下:

<div class="select2-drop select2-display-none select2-with-searchbox select2-drop-active" style="display: block; left: 7.5px; width: 465px; top: 156.75px; bottom: auto;" id="select2-drop" xpath="1">   <div class="select2-search">       
<label for="s2id_autogen21_search" class="select2-offscreen">Case</label>       
<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" class="select2-input" role="combobox" aria-expanded="true" aria-autocomplete="list" aria-owns="select2-results-21" id="s2id_autogen21_search" placeholder="" aria-activedescendant="select2-result-label-25">
</div>
<ul class="select2-results" role="listbox" id="select2-results-21"><li class="select2-results-dept-0 select2-result select2-result-selectable select2-highlighted" role="presentation">
<div class="select2-result-label" id="select2-result-label-25" role="option">
<span class="project">XXXLutz vs Mobelix</span><br><span class="client">Wisozk - Turner</span></div></li></ul></div>

我尝试了下一个代码:

cy.get(this.elements.caseNameSelector).trigger('mousemove').click()
            .get('.select2-search input').eq(4)
            .type(caseName, {force:true})
            .wait(2000)
            .get('.select2-result-label 
    .project').trigger('mousemove').click({force:true})`

也尝试过:

cy
    .get(this.elements.caseNameSelector).trigger('mousemove').click()
    .get('.select2-search input').eq(4).type(caseName).type('{enter}', 
     { release: false }).get('.select2-result-label .project').click()

0 个答案:

没有答案