Code Monkey home page Code Monkey logo

Comments (5)

jennifer-shehane avatar jennifer-shehane commented on August 15, 2024

@tester-at-bmi Could you try updating to the latest Cypress version? Your issue may already be fixed.

I have to say, I haven't seen this before. This behavior doesn't occur in Chrome? Have you ensured your website doesn't have a bug in Firefox when typing outside of Cypress?

from cypress.

tester-at-bmi avatar tester-at-bmi commented on August 15, 2024

@tester-at-bmi Could you try updating to the latest Cypress version? Your issue may already be fixed.

I have to say, I haven't seen this before. This behavior doesn't occur in Chrome? Have you ensured your website doesn't have a bug in Firefox when typing outside of Cypress?

@jennifer-shehane On Chrome/Edge this behavior is not there when running the tests.
When i test the login manually everything is ok on firefox.
Wil report back later this week doing the test on the latest version of Cypress.

EDIT Also with the latest version of Cypress (13.6.4) i have te same issue/result.
Could it be an issue because of cy.session/cy.origin somehow where the typing is hapening?

I'm going to create another test later today that test the application itself to see if i can rule that out.

from cypress.

tester-at-bmi avatar tester-at-bmi commented on August 15, 2024

@jennifer-shehane 👌 so it seems that it has to do with my current setup that i provided urlier.

I tried the test directly on keycloak and that seems to work just fine.

So my best guess is it is an issue with my code that i provided that uses cy.session/cy.origin.

This code fails

export function loginViaGui(username: string, password: string): void {
	cy.session(
		[username, password],
		() => {
			cy.visit('/');
			cy.origin(Cypress.env('BMI_AIP_KEYCLOAK'), { args: { username, password } }, ({ username, password }) => {
				cy.get('#username').should('be.visible').type(username);
				cy.get('#password').should('be.visible').type(password);
				cy.get('#kc-login').should('be.visible').click();
			});
		},
		{ cacheAcrossSpecs: true },
	);
	cy.visit('/');
	cy.url().should('eq', `${Cypress.config('baseUrl')}/`);
}

So this will work.

describe('Keycloak', () => {
	context('Login with valid user credentials', () => {
		beforeEach('Visit login page', () => {
			cy.visit('KEYCLOAK_URL');
		});

		describe('Should be able to login with a valid user account', () => {
            it('Should be able to login with a admin account', () => {
                cy.get('#username').should('be.visible').type('ADMIN');
                cy.get('#password').should('be.visible').type('PASSWORD');
                cy.get('#kc-login').should('be.visible').click();
            });
		});
	});
});

from cypress.

jennifer-shehane avatar jennifer-shehane commented on August 15, 2024

It's a bit strange. 🤔

from cypress.

tester-at-bmi avatar tester-at-bmi commented on August 15, 2024

Have a workaround for the 1st part.

export function loginViaGui(username: string, password: string): void {
	// eslint-disable-next-line @typescript-eslint/no-shadow
	cy.session(
		[username, password],
		() => {
			cy.visit('/');
			cy.url().should('eq', `${Cypress.config('baseUrl')}/`);
			cy.origin(Cypress.env('BMI_AIP_KEYCLOAK'), { args: { username, password } }, ({ username, password }) => {
				//Cypress.on('uncaught:exception', () => false);
				if (Cypress.isBrowser({ family: 'chromium' })) {
					cy.get('#username').should('be.visible').type(username, {
						log: false,
					});
					cy.get('#password').should('be.visible').type(password, {
						log: false,
					});
				} else {
					cy.get('#username').should('be.visible').invoke('val', username).trigger('input');
					cy.get('#password').should('be.visible').invoke('val', password).trigger('input');
				}
				cy.get('#kc-login').should('be.visible').click();
			});
		},
		{ cacheAcrossSpecs: false },
	);
	cy.visit('/');
	cy.url().should('equal', `${Cypress.config('baseUrl')}/`);
	cy.get(SIDEBAR_LEFT.sidebarLeft, { timeout: 5000 }).should('be.visible');
}

1st test succeeds now and session is created.
All following test fails...
The session gets restored (seems that way) and then it goes to the application url and than i'm thrown back at the origin url (should have sticked at the application url).

from cypress.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.