Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

239
Visualizações
SSO Login in Cypress

enter image description herethe app that I test has SSO login. So, 1st I am cy.vist(xxx) to one URL then system directs me another cy.visit(yyy). But currently I cant handle the issue that currently I am facing. Can you please help me to figure out?

Thank you

it.only("logs in using env variables", () => {
    
    const username = Cypress.env("username");
    const password = Cypress.env("password");
    let href;

    cy.visit("/");
    cy.get(".chakra-stack > .css-1n94901").click()
    

    cy.contains("Login with Carmarket").click();

    cy.get(":nth-child(1) > .form-control").type(username);
      
      cy.get(":nth-child(2) > .form-control").type(password);
      
      cy.get(".login > .submit > .button").click({multiple: true,force: true});
      

    cy.url().then((url) => {
      href = url;

      cy.log("href ", href);


      cy.visit(href);
      cy.url().should("include", "blabla[][1]][1]"); //assertion of that we are in this url
    });
  });
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

After clicking the login button, you can directly assert whether url contains some text. Also you can add some timeout as well for the redirection to complete.

cy.url({timeout: 6000}).should("include", "blabla[][1]][1]")

Considering your url is https://example.com/ Within the same test you can work with urls if they have format like https://example.com/something or https://example.com/something/123 or https://superdomain.example.com/. So basically the url should have the same origin. But in case the url is not from the same origin which is in your case, then you have to move to a new test to resolve this. This is a trade-off of cypress and you can read more about it from here. So you can do something like this:

it('logs in using env variables', () => {
  const username = Cypress.env('username')
  const password = Cypress.env('password')
  let href
  cy.visit('/')
  cy.get('.chakra-stack > .css-1n94901').click()
  cy.contains('Login with Carmarket').click()
  cy.get(':nth-child(1) > .form-control').type(username)
  cy.get(':nth-child(2) > .form-control').type(password)
  cy.get('.login > .submit > .button').click({multiple: true, force: true})
})

it('validate content of url', () => {
  cy.url({timeout: 6000}).should('include', 'blabla[][1]][1]')
})
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda