最近,这些参数已更改,现在不再将URL空间编码为链接上URL的一部分,例如:
:
<a href="someproduct?myParam=some product name">
出于某种原因,浏览器以太将其转换为myParam=some%20product%20name
myParam=some+product+name
,因此有时我的测试可以工作,有时它们不行。
有一种方法可以测试这两种情况吗?例如:
const expectedPathA = "myParam=some%20product%20name";
const expectedPathB = "myParam=some+product+name";
cy.url().should('include', (expectedPathA || expectedPathB);
本页
评论给出了各种复杂断言的例子。最直接的可能是
cy.url().should('be.oneOf', [baseUrl + expectedPathA, baseUrl + expectedPathB])`