From 07a42042c503e5710e9804c8045add696a1a660b Mon Sep 17 00:00:00 2001 From: Shivam Pandey Date: Wed, 17 Apr 2024 21:31:59 +0530 Subject: [PATCH] Auto Upgradation and Premium Tatkal --- cypress/e2e/irctc.cy.js | 24 ++++++++++++++++++++++-- cypress/fixtures/passenger_data.json | 11 ++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/cypress/e2e/irctc.cy.js b/cypress/e2e/irctc.cy.js index 78ea254..9ac03be 100644 --- a/cypress/e2e/irctc.cy.js +++ b/cypress/e2e/irctc.cy.js @@ -1,7 +1,7 @@ let username = Cypress.env('USERNAME') let password = Cypress.env('PASSWORD') -import { PASSENGER_DETAILS, SOURCE_STATION, DESTINATION_STATION, TRAIN_NO, TRAIN_COACH, TRAVEL_DATE, TATKAL, BOARDING_STATION, UPI_ID_CONFIG } from '../fixtures/passenger_data.json' +import { PASSENGER_DETAILS, SOURCE_STATION, DESTINATION_STATION, TRAIN_NO, TRAIN_COACH, TRAVEL_DATE, TATKAL, PREMIUM_TATKAL, BOARDING_STATION, UPI_ID_CONFIG } from '../fixtures/passenger_data.json' Cypress.on('uncaught:exception', (err, runnable) => { // returning false here prevents Cypress from @@ -13,6 +13,11 @@ Cypress.on('uncaught:exception', (err, runnable) => { describe('IRCTC TATKAL BOOKING', () => { it('Tatkal Booking Begins......', () => { // Catching Load Event Exception.. + if (TATKAL && PREMIUM_TATKAL) { + expect(false, 'Make Sure Either TATKAL or PREMIUM TATKAL is True. Not BOTH').to.be.true; // Ensure at least one variable is true (or both are false) + + } + cy.clearCookies() cy.clearLocalStorage() cy.viewport(1478, 1056) @@ -55,6 +60,7 @@ describe('IRCTC TATKAL BOOKING', () => { cy.get('.ui-calendar').type(TRAVEL_DATE) + // TATKAL or NORMAL BOOKING if (TATKAL) { cy.get('#journeyQuota > .ui-dropdown').click() @@ -62,6 +68,12 @@ describe('IRCTC TATKAL BOOKING', () => { } + if (PREMIUM_TATKAL) { + cy.get('#journeyQuota > .ui-dropdown').click() + cy.get(':nth-child(7) > .ui-dropdown-item').click() + + } + // search button cy.get('.col-md-3 > .search_btn').click() @@ -185,17 +197,25 @@ describe('IRCTC TATKAL BOOKING', () => { - // For Selecting "Book only if confirm berths are allotted."" + + // For Selecting "Book only if confirm berths are allotted."" as well as Auto Upgradation cy.get('body').then((el) => { if (el[0].innerText.includes('Book only if confirm berths are allotted')) { cy.get(':nth-child(2) > .css-label_c').click() } + if (el[0].innerText.includes('Consider for Auto Upgradation.')) { + cy.contains('Consider for Auto Upgradation.').click() + + } }) + + + // Choosing UPI As Payment Option while filling passenger details cy.get('#\\32 > .ui-radiobutton > .ui-radiobutton-box').click() diff --git a/cypress/fixtures/passenger_data.json b/cypress/fixtures/passenger_data.json index 18e4d39..47045a0 100644 --- a/cypress/fixtures/passenger_data.json +++ b/cypress/fixtures/passenger_data.json @@ -1,11 +1,12 @@ { - "TRAIN_NO": "18464", - "TRAIN_COACH": "2A", - "TRAVEL_DATE": "07/05/2024", - "SOURCE_STATION": "DHNE", + "TRAIN_NO": "12559", + "TRAIN_COACH": "SL", + "TRAVEL_DATE": "18/04/2024", + "SOURCE_STATION": "BSBS", "BOARDING_STATION": null, - "DESTINATION_STATION": "BBS", + "DESTINATION_STATION": "NDLS", "TATKAL": false, + "PREMIUM_TATKAL": true, "UPI_ID_CONFIG": "", "PASSENGER_DETAILS": [ {