简体   繁体   English

带有剑道下拉菜单的 Cypress 测试

[英]Cypress tests with kendo dropdown

I'm working for the first time with Cypress to automate some tests, and I'm pleased with that, but now I'm stuck on something simple.我第一次与 Cypress 合作以自动化一些测试,对此我很满意,但现在我被困在一些简单的事情上。

We are using kendo to render a dropdown (in the HTML it is a standard select, with kendo-drop-down-list attribute).我们正在使用 kendo 来呈现一个下拉列表(在 HTML 中它是一个标准的选择,带有 kendo-drop-down-list 属性)。

In the rendered page, I can see the select item with the possible values, but it is set as not visible, so cypress cannot click and select on this.在呈现的页面中,我可以看到带有可能值的选择项,但它被设置为不可见,因此 cypress 无法单击并选择它。

It looks like that every time I select an option, the DOM is dynamically modified to show me the dropdown as a set of span elements, that are created on the fly.看起来每次我选择一个选项时,DOM 都会动态修改,以将下拉列表显示为一组动态创建的 span 元素。

This is what I'm doing in Cypress (where sDir is the id of the select element and firstValue is the first option of the dropdown list)这就是我在 Cypress 中所做的(其中sDir是选择元素的 id,而firstValue是下拉列表的第一个选项)

    cy.get('#sDir').select('firstValue')

Which is the right way to interact with a kendo drop down with Cypress?哪个是与 Cypress 的剑道下拉交互的正确方法?

Thanks谢谢

Saw some other posts related to this, but I'm using the following method to interact with kendo drop down:看到了一些与此相关的其他帖子,但我使用以下方法与剑道下拉菜单进行交互:

cy.get('[data-container-for="YourItem"] > .k-widget > .k-dropdown-wrap > .k-select').click({force: true})
cy.get('.k-list-filter > .k-textbox').type('Value')
cy.get('k-list-scrooler').contains('Value').click()

You may have to use click({force: true})您可能必须使用click({force: true})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM