【问题标题】:Need help in cypress to read data from excel/csv在 cypress 中需要帮助以从 excel/csv 读取数据
【发布时间】:2019-05-30 15:29:32
【问题描述】:

我正在尝试从 excel 中读取测试用例,然后将其传递给 cypress 执行。

我想要的是我的 excel 将包含所有网站

abc.com, example.com ,xyz.com

喜欢50到100个这样的网站

然后将其传递给 cypress,cypress 将为每个站点执行 100 个站点。

我尝试通过阅读 cypress 插件来做到这一点,但不太确定如何做到这一点。任何指导都会非常有帮助

我的目标是为超过 100 个网站运行测试用例,例如该网站正在加载

有什么建议吗?

【问题讨论】:

    标签: node.js cypress


    【解决方案1】:

    您可以使用 Cypress Module API 以编程方式执行此操作,方法是每次更改测试的 baseUrl

    这样的东西应该可以工作,就像 Node 脚本一样:

    const cypress = require('cypress')
    
    const baseUrlList = loadSitesFromExcel()
    
    // create a recursive Promise chain
    function runTests(i = 0) {
      if (i == baseUrlList.length) {
        return Promise.resolve()
      }
    
      return cypress.run({
        config: {
          baseUrl: baseUrlList[i]
        }
      })
      .then((results) => {
        // do something with results, then run next test
        return runTests(i + 1)
      })
    }
    
    // begin
    runTests()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-10
      • 1970-01-01
      • 1970-01-01
      • 2014-04-10
      相关资源
      最近更新 更多