Reputation: 89
Hello Now I learn testing with cypress.io but I dont know how accept cookies with cypres.
cy.get('button accept class').click()
This code dont work I want accept cokies on
https://www.kiwi.com/en/
Upvotes: 0
Views: 7097
Reputation: 335
Or you could just go by storing the cookie you check to show you cookie banner.
describe("Test", () => {
beforeEach(() => {
cy.setCookie(
"cookies_consent",
JSON.stringify({ cookies_analytics: "granted", cookies_marketing: "granted" })
);
});
Upvotes: 0
Reputation: 89
Thank you than I find little mistake in my code.
cy.get('[data-test=acceptCookies]:visible').click()
Thank you here is my code
Upvotes: 0
Reputation: 31
One 'brutal' way to do it :
describe('Test Suite MakeMyTrip', function(){
it('Test Demo', function(){
cy.visit('https://www.kiwi.com/en/')
cy.get('section.ModalSection__StyledModalSection-sc-1ayrdn8-0 button').contains('Accept').click({force: true})
})})
I suggest you start learning css selectors : https://www.w3schools.com/cssref/css_selectors.asp or you won't be able to select the element you want to test.
Upvotes: 2