其他测试框架 Cypress - 疑难杂症

非洲赵子龙 for Cypress · June 22, 2019 · Last by 分手丶锅带走 replied at January 04, 2021 · 3103 hits

翻译工作即将结束,中文版文档即将面世,特开一题,专门对在使用 Cypress 过程中遇到的的疑难杂症进行列举,以便所有人参考。

共收到 16 条回复 时间 点赞

超级赞!
😋 😋 😋 😋

目前卡在持续集成这个步骤,有点头晕

Cypress 如何处理新开页面的情况?

jxd98 回复

this FYI.

vue 组件化的下拉框选项点击不到,一直报
CypressError: Timed out retrying: cy.click() failed because this element is not visible:

  • This element '

    ' is not visible because its parent '' has CSS property: 'display: none'

    Fix this problem, or use {force: true} to disable error checking.

    https://on.cypress.io/element-cannot-be-interacted-with

    代码实现是这样的:
    cy.get('.ivu-form-item-label').contains('关联方标识').next().click()
    cy.contains('ul li', '是').click()

    加了 force:true 后,不报错,但是点击不生效

    @jianghubren 有 HTML 源码吗? 或者你们站点如果对外开放的话,给我站点也行,帮你调试一下

    已经解决掉了,谢谢,现在又碰到一个新问题,正在慢慢研究中

    jianghubren 回复

    嗯 加油~

    在 Linux 环境下执行 npm run cysit 的命令时,报错:
    root@test:/home/ln/cypress/test-quality_testing# npm run cysit

    test-quality_testing@1.0.0 cysit /home/ln/cypress/test-quality_testing
    node scripts/cypress.js --env-sit

    It looks like this is your first time using Cypress: 4.5.0

    ✖ Verifying Cypress can run /root/.cache/Cypress/4.5.0/Cypress
    → Cypress Version: 4.5.0
    err Error: Cypress failed to start.

    This is usually caused by a missing library or dependency.

    The error below should indicate which dependency is missing.

    https://on.cypress.io/required-dependencies

    If you are using Docker, we provide containers with all required dependencies installed.


    (Cypress:28352): Gtk-WARNING **: 14:49:34.173: cannot open display: localhost:10.0


    Platform: linux (Ubuntu Linux - 18.04)
    根据这个报错信息,在安装了对应的依赖后再次执行命令行时仍报错,有人遇到过这种问题吗?

    Test_nian 回复

    试下修复下 node.js

    liuwj · #11 · June 15, 2020
    Author only

    最近初学 cypress ,在使用 text() 获取文本数组时,得到的是一个 object 对象,而不是一个类似于 ["xxx","xxxxx","bbbbb"] 的数组呢。请问如何得到一个数组呢。

    类似https://docs.cypress.io 页面选择语言的模拟用户点击选择的操作应该如何处理?

    Zhengjun Han 回复

    不需要你点击,直接用select即可:

    describe("cypress首页", function() {
        // 登陆
        beforeEach("切换语言", function() {
            cy.visit("/guides/overview/why-cypress.html#In-a-nutshell");
        });
        it("切换语言 > 中文", function() {
            cy.get("#lang-select").select("zh-cn");
            cy.get(".article-title").should(($title) => {
                expect($title.first()).to.contain("为什么");
            });
        });
    });
    
    土豆 回复

    不清楚你的数据真实类型,但是判断一个数据是否是数组不能用typeof,需要用Array.isArray(x)进行判断。

    @ 非洲赵子龙 请问 cypress 怎么定位伪元素?

    非洲赵子龙 关闭了讨论 07 May 15:46
    需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up