Skip to content

Commit

Permalink
checking isValidUpiID
Browse files Browse the repository at this point in the history
  • Loading branch information
shivamguys committed Apr 10, 2024
1 parent c47ca3c commit 3a10172
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/irctc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ on:
type: string
description: "Your IRCTC Password"
UPI_ID:
default: ""
required: false
type: string
description: "Your UPI ID To Make Payment From"
Expand Down Expand Up @@ -56,4 +55,4 @@ jobs:
uses: cypress-io/github-action@v6
with:
browser: chrome
command: npx cypress run --record --key a15b31a6-b9ee-4678-b9ac-f45a190851fe --env UPI_ID=${{ env.UPI_ID }},USERNAME=${{ inputs.USERNAME || secrets.USERNAME }},PASSWORD=${{ inputs.PASSWORD || secrets.PASSWORD }}
command: npx cypress run --record --key a15b31a6-b9ee-4678-b9ac-f45a190851fe --env UPI_ID=${{ inputs.UPI_ID || '' }},USERNAME=${{ inputs.USERNAME || secrets.USERNAME }},PASSWORD=${{ inputs.PASSWORD || secrets.PASSWORD }}
6 changes: 5 additions & 1 deletion cypress/e2e/irctc.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ describe('IRCTC TATKAL BOOKING', () => {
cy.visit('https://www.irctc.co.in/nget/train-search')
cy.task("log", `Website Fetching completed.........`)
const UPI_ID = Cypress.env().UPI_ID ? Cypress.env().UPI_ID : UPI_ID_CONFIG;
const upiRegex = /^[a-zA-Z0-9]+@[a-zA-Z0-9.]+$/;

const isValidUpiId = upiRegex.test(UPI_ID);

cy.get('.h_head1 > .search_btn').click()
cy.get(':nth-child(1) > .form-control').invoke('val', username).trigger('input')
cy.get(':nth-child(2) > .form-control').invoke('val', password).trigger('input')
Expand Down Expand Up @@ -228,7 +232,7 @@ describe('IRCTC TATKAL BOOKING', () => {
console.log(interception.response.body)

// MAKE SURE UPI ID EXIST THEN PROCEED PLEASE FILL UPI_ID VALUE IN cypress/fixtures/passenger_data.json as something like this "123713278162@paytm"
if (UPI_ID) {
if (UPI_ID && isValidUpiId) {
cy.get('#ptm-upi').click()
cy.get('.brdr-box > :nth-child(2) > ._1WLd > :nth-child(1) > .xs-hover-box > ._Mzth > .form-ctrl').type(UPI_ID)
cy.get(':nth-child(5) > section > .btn').click()
Expand Down

0 comments on commit 3a10172

Please sign in to comment.