柏树断言

时间:2019-12-10 03:29:43

标签: testing autocomplete cypress

我有一个关于赛普拉斯断言的问题,最近才开始使用该测试平台,但是当URL返回如下所示的随机数时被卡住了。

/Geocortex/Essentials/REST/sites/SITE?f=json&deep=true&token=SK42f-DZ_iCk2oWE8DVNnr6gAArG277W3X0kGJL1gTZ7W5oQAAV9iC4Zng4mf0BlulglN-10NK&dojo.preventCache=1575947662312

您可以看到令牌是随机的,而 dojo.preventCache 也是随机字符串。我想检测此URL,并检查 deep = true 是否与令牌编号无关,但是我不知道该如何实现。

cy.location('origin', {timeout: 20000}).should('contain', '/Geocortex/Essentials/REST/sites/SITE?f=json&deep=true&token=**&dojo.preventCache=**');

有人知道吗?

1 个答案:

答案 0 :(得分:1)

您可以像这样检查路径和查询(请注意,cy.location('origin')既不会产生pathname也不会产生query,因此我使用的是{{1 }}):

cy.url()

或分别检查:

cy.url()
    .should('contain', '/Geocortex/Essentials/REST/sites/SITE')
    .should('contain', 'deep=true');

或者,使用自定义回调在其中进行操作并声明所需的内容:

cy.location('pathname').should('contain', '/Geocortex/Essentials/REST/sites/SITE');
cy.location('search').should('contain', 'deep=true');