0

I am trying to automate a web application where I have a login page- eg-

test.webapplication.com.

After successful login, the url changes and it becomes something like

mycm.home.site.com.

I am not able to achieve this with cypress within one test. After login, the cypress runner disappears and the test don't go further to execute. Is there any solution for this?

Added more description-

before login-

it('Login', function()

cy.visit('loginurl')

cy.get("#username").type("username")
cy.get("#password").type("password")

cy.get("#Login").click() //here, after login url is getting changed 

So, below action will happen on a new url(homepage), but cypress runner closes because the url is changing after login, hence not able to proceed After login-

cy.get("#firstfield").type("abc)
cy.get("#secondfield").type("xyz)

  • 1
    Log in not via a UI. You can also visit different domains in different tests. https://docs.cypress.io/guides/references/trade-offs#Same-origin – pavelsaman Jun 07 '21 at 08:03
  • Perhaps this recipe [logging-in-html-form](https://github.com/cypress-io/cypress-example-recipes/blob/dce2d5db8d7a74bc685ca16b301d0fa3b4164318/examples/logging-in__html-web-forms/cypress/integration/logging-in-html-web-form-spec.js#L92) –  Jun 07 '21 at 08:11
  • But are you using the component test runner? Please show what your test looks like. –  Jun 07 '21 at 08:12
  • @pavelsaman I can visit second domain in different test, but it doesn't keep me login state. I have to login and then keep myself in logged in mode to perform further actions. – user2914704 Jun 07 '21 at 09:42
  • You can get the authentication with `cy.request()` then `cy.visit()` the home site. Please provide more details so that an appropriate example can be given. –  Jun 07 '21 at 09:59
  • @BarmyFotheringay-Phipps added extra info – user2914704 Jun 07 '21 at 10:09
  • @SteveZodiac added the test info, please check – user2914704 Jun 07 '21 at 10:14
  • Great, that seems to meet the requirements for the recipe linked above. All you need to do is find the url that `cy.get("#Login").click()` sends to, and use `cy.request()` instead of filling the form. –  Jun 07 '21 at 11:39
  • @BarmyFotheringay-Phipps I should put cy.request() in the same test or different test? even after assertion, once it is logging in, the runner closes- it says- "Your tests are running" and then it disappears without moving to second test. – user2914704 Jun 07 '21 at 17:25

0 Answers0