Tested page URL:
Test code
I do not want to log in every time I use the test case
Hi @haoshasha,
The User Roles feature should meet your need.
Hello @AlekseyMartynov i tried using User Roles feature, but it's always failed when i try switch roles
can you provide an example how to use it as the helpers file? Thanks!
Hi @fkartika,
Take a look at the An Easier Way to Authenticate Users in E2E Tests article.
You can find an example in the Example: Authenticating on GitHub section there.
Thanks for the reply @AlekseyMartynov !
and then i found the problem is the first credential still stored on session, so when i switch to other role the page is reloaded to login page, but not with the new credential. It's still previous credential. I test an Angular page. Do you know why this is happening?
@fkartika Do you reproduce the same for example on github.com with the same test code?
no @AlexanderMoskovkin it's not happen in your example. Your example works well.
In this case it seems the problem is specific for you page. Could you please share your page and test code with us or create a simple example that allows to reproduce the problem on our side?
Meanwhile try to set the preserveUrl option to true. It possible it has a sense for your project.
Is that settled?
@haoshasha TestCafe runs each test in a clear environment (with empty cookie, local storage etc..). Have you tried the User Role feature? Does it meet your need?
@AlexanderMoskovkin I'll try it
@AlexanderMoskovkin Each test case requires each login锛宐ut I don't want to
This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.
Most helpful comment
@haoshasha TestCafe runs each test in a clear environment (with empty cookie, local storage etc..). Have you tried the User Role feature? Does it meet your need?