如何单击按钮直到满足条件

发布于 2025-02-04 05:41:00 字数 1400 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

关于从前 2025-02-11 05:41:00

在您的情况下,我会尝试使用 mutationObserver > observer(< yourdaypickerelement>),通过添加nodes循环以找到一个具有“ March” TextContent的节点。

我相信您可以设置&使用cy.window()。然后(()=> {new MutationObserver ...}),然后找到“三月”文本,您可以调用cy。单击以便打开。

一种更简单的方法是使用等待& 期望(< YourDayPicker>)。

In your case I'd try using MutationObserver to observer(<yourDayPickerElement>), loop through addedNodes to find a node that has "March" textContent for example.

I believe in Cypress you can setup & run the observe with cy.window().then(() => { new MutationObserver... }), then once the "March" text is found you can call cy.click on so on.

A more simpler approach would be using wait & expect(<yourDayPicker>).<toHaveMatchText...>, but it's less accurate and can sometimes fail if you're unsure how to expect for that "March" text.

囚我心虐我身 2025-02-11 05:41:00

没有代码很难正确回答,但可能是类似的:

function recursiveFunction() {
    cy.get("#your-previous-month-selector").click().then(()=>{
        if(cy.get("#your-month-display").innerText!='March')
            recursiveFunction();
        else
            assert(true) // or return something
    })
}

With no code is hard to answer properly but could be something similar:

function recursiveFunction() {
    cy.get("#your-previous-month-selector").click().then(()=>{
        if(cy.get("#your-month-display").innerText!='March')
            recursiveFunction();
        else
            assert(true) // or return something
    })
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文