【发布时间】:2019-08-19 14:29:20
【问题描述】:
如果您已登录,在赛普拉斯中是否有可能从页面注销?或者检查我是否已登录?
我的问题是,如果我在浏览器中运行测试,那么赛普拉斯总是需要登录。但是如果我从 cmd 启动它,它只需要在第一个测试时登录,但在下一个测试时你已经已登录。
// Visit the site
cy.visit(
"https://zeteodemo.uat.creasoft.cz/login?ReturnUrl=%2fVehicleInsuranceV2%2fCompare%3fOsobniCislo1%3d1%26ProductsFilter%3dAXA-ONLINE"
);
// Enter username
cy.get(".login__username")
.type("tester")
.should("have.value", "tester");
// Enter password
cy.get(".login__password")
.type("1")
.should("have.value", "1");
// Click the login button
cy.get(".button-login").click();
【问题讨论】:
-
我可能完全不在这儿,对你会得到什么答案很感兴趣。但是您是否考虑过使用 cookie (docs.cypress.io/api/cypress-api/cookies.html#Syntax)?赛普拉斯会在每次测试后删除 cookie,但您可以保留登录用户的 cookie,根据其值决定是否需要单击登录按钮。这只是一个想法,以前从未这样做过..
-
是的,我正在尝试使用 cookie,但它不起作用。也许我没有正确使用它们,所以我在问。
标签: javascript testing automation automated-tests cypress