当cy.wait被调用2次以上时,为cy.route创建别名不起作用

时间:2018-09-16 19:30:46

标签: automation cypress

我为特定路线设置了别名。当它第一次被调用时,它可以完美地工作。但是我在自动化脚本中多次调用相同的后期操作。这会影响cy.wait()行为,最终导致超时错误,并且服务器无响应。

Cy.route("POST","*/*/ABC/METHODNAME").as("getDataFromServer"); // executed 4 times
Cy.route("POST","*/*/ABC/SecondMETHODNAME").as("getDataFromMethod2"); // executed 6 times
Cy.route("POST","*/*/ABC/THIRDMETHODNAME").as("getFromMethod3"); // actual request which will give the page output (html code)

cy.wait(["@getDataFromServer","@getDataFromServer","@getDataFromServer","@getDataFromMethod2","@getDataFromMethod2","@getDataFromMethod2","@getDataFromMethod2","@getDataFromServer","@getDataFromMethod2","@getDataFromMethod2","@getFromMethod3"];
cy.get(); // rest of the code assert and expect;

我在getDataFromServer之前有多个呼叫getDataFromMethod2getFromMethod3的电话。所以,我等了。 使用RUN ALL TESTS随机运行的几个脚本运行所有这些脚本时,编写了35个脚本。

cy.Wait()超时等待“ @ getDataFromMethod2”的第3个响应的100000ms。服务器未响应。 或有时抛出 {@ {1}}超时等待“ @ getDataFromMethod2”的第5个响应的100000ms。服务器未响应。 enter image description here

0 个答案:

没有答案