【问题标题】:How to handle if we are using two different urls in one cypress test如果我们在一个 cypress 测试中使用两个不同的 url,如何处理
【发布时间】:2021-09-29 09:45:35
【问题描述】:

我有一个要求,我需要访问第一个 URL(ex-www.example.com)并执行一些 AWS 操作,例如验证 AWS S3 中的文件。完成所有操作后,它应该在同一个测试中转到第二个 URL(ex-www.example1.com)。需要解决方案吗?

【问题讨论】:

  • 请提供足够的代码,以便其他人更好地理解或重现问题。

标签: javascript node.js cypress


【解决方案1】:

您必须单独运行它们才能正常工作。

  it("Test", function () {
    cy.visit('ex-www.example.com');
    aws operations here

  });

  it("Test", function () {
    cy.visit('ex-www.example1.com');
  });

如果你试试这个:

  it("Full Happy Test", function () {
    cy.visit('ex-www.example.com');
    aws operations here
    cy.visit('ex-www.example1.com');

  });

你会得到这个错误:

"cy.visit() failed because you are attempting to visit a URL that is of a 
different origin."

【讨论】:

    猜你喜欢
    • 2019-08-10
    • 1970-01-01
    • 2012-01-23
    • 2015-03-15
    • 2017-11-12
    • 2022-09-23
    • 1970-01-01
    • 2023-02-13
    • 1970-01-01
    相关资源
    最近更新 更多