I must go through a login of a different app in order for my own app to be working, I can't mock that. So the first line I do is as described below - I use cy.visit(..)
to go to that page an log in. However, often when it starts the test, instead of visiting that page and fill the form to login, the entire Chrome tab goes redirects there (rather than just the app on the righthand side panel) and the testing panels are gone as if I just opened a new tab in Chrome and went to that page. I have to kill the cypress process and restart it. That usually fixes it, if not I just restart it a couple more times.
Testing proceeds as normal.
Maybe try to visit a different domain?
cy.visit(`https://different.app.com/session?redirect=${encodeURIComponent(myAppUrl)}`);
Cypress: 2.1.0
OS: MacOS High Sierra 10.13.3
Browser: Chrome 66
If I'm understanding your question properly - this is a commonly asked question that's been answered on other various issues with links to how to do this properly. The short answer is you don't cy.visit
the other app - you programmatically interact with it with cy.request
.
Here's some other answers.
Feel free to reopen this issue if you feel this is not adequate enough.
Thanks for the quick response!
I forgot to mention that the other page's login is rather intricate, using iframes and several redirects and as you suggested I initially tried to use the cy.request
method and it didn't seem to work. Not sure if I can make it work using only programatic requests. Is there an alternative?
I think it will work eventually, was just wondering if there's a different way. In any case, I'll work harder on that cy.request
.
Hello,
We are actually evaluating which solution to use for end2end testing in our project.
Cypress seems great, it has a nice developer experience, and good documentation/examples/etc.
But we hit a wall with the login step of our backoffice application because of the iframe/multiple domains restrictions.
I know there are a lot of informations and even a sample on how to get this kind of scenario working, but as we are not the team developing the backend and the authentification services, this is just a show stopper for us...
That and a straight forward way of running multiple test suites in parallel without a docker master degree
Sorry i don't want to seem rude, but i'm actually sad that we can not go further with cypress, as i feel it has great potential. I just wanted to share that.
@ricovitch which e2e solution did you end up going with?
@lyonsbp i still think cypress is a great solution, but we had to make a pragmatic choice and we went with testcafe.
I think my complaint about concurrency is no longer valid with the latests cypress releases. But we still had no solution for the multiple domain login flow.
This is a big blocker for me and my team. I am trying to work around it using cy.request
but i am not able to follow redirects using the location
property in my requests' response.
I'm hitting a similar wall, my login has a window.confirm
then does a redirect that has iframes. The test runner always show the view, "Whoops, there is no test to run." No matter what I do, I can't get beyond this barrier. If I hit the back button, the test re-runs and the same "...no test to run." screen.
I've tried:
https://docs.cypress.io/api/events/catalog-of-events.html#Window-Confirm
https://gitter.im/cypress-io/cypress/archives/2017/09/05
https://github.com/cypress-io/cypress/issues/621
I really like this tool and how intuitive and great feedback it has and stepping through the test steps showing the state of the UI with before/after...but I can't log into the app, I can't use this tool.
@brian-mann i'm not sure why this is closed. this is a really big blocker for us as well and can't get passed this redirect bug. Already wrote a LOT of tests for Cypress and would hate to have to move to something else because of something so silly.
Usecase:
/page
immediately redirects to /page/hi
but there is no way to test that this redirect happens. Cypress throws a 404 for some reason when the browser clearly redirects for the end user.
js
it('properly load menu url', () => {
// Page should probably redirect to a default landing if plugged in randomly.
cy.visit('/page')
.location('pathname', { timeout: 10000 })
.should('eq', '/page/hi');
});
Yeah i'm having a similar issue.
Doing the following steps:
_even_ if - let's say 3 - redirects would happen (don't ask me why, login process..), then I would expect another assert with cy.location('href) would do the trick for me. Especially if I pass a timout of let's say 15 seconds (ignoring the fact that that might itself be a bad thing to do for now).
@bgold0 @jiimaho Please open a new issue with a completely reproducible example (test code that we can run and demonstrate the problem). We can't run code that is cy.visit('/page')
for example to debug your exact problem and work on a fix. So until we are provided with your usecase, we can't move forward.
Most helpful comment
@brian-mann i'm not sure why this is closed. this is a really big blocker for us as well and can't get passed this redirect bug. Already wrote a LOT of tests for Cypress and would hate to have to move to something else because of something so silly.
Usecase:
/page
immediately redirects to/page/hi
but there is no way to test that this redirect happens. Cypress throws a 404 for some reason when the browser clearly redirects for the end user.js it('properly load menu url', () => { // Page should probably redirect to a default landing if plugged in randomly. cy.visit('/page') .location('pathname', { timeout: 10000 }) .should('eq', '/page/hi'); });