Pay with a card inside a payment iframe
Hard85 pts~2 min
- Iframes
- Frame switching
- Cross-document messaging
- Enabled state
Practice app · SkyWay
An online travel agency: airport autocomplete, a custom calendar, travellers popover, timed search results with sorting and filters, a fare modal, passenger validation, a seat map, card payment inside an iframe, and a manage-booking page with native confirm and prompt dialogs.
Your starter code already declares TEST_URL — never hardcode a host.
Objective
The card form is in a same-origin iframe. Show that a declined card is rejected, verify the test card inside the frame, then return to the main page, pay, and confirm the booking.
Your task
- 1Open TEST_URL. A booking for 1 adult with seat 12A is already at the payment step.
- 2Switch into the iframe #payment-frame. Enter 4000 0000 0000 0002 in #card-number, 12/29 in #card-expiry and 123 in #card-cvv, click #verify-card and assert #card-error mentions the card was declined.
- 3Replace the card number with 4111 1111 1111 1111, click #verify-card and assert #card-status reads “Card verified”.
- 4Switch back to the main page and assert #card-state reads “Visa ending 1111 verified” and #pay-now is enabled.
- 5Click #pay-now and wait for the confirmation page.
- 6Assert #confirmation-heading reads “Booking confirmed”, #pnr-code shows a PNR and #paid-with reads “Visa ending 1111”.
Acceptance criteria
- The declined card is rejected inside the frame.
- The test card is verified inside the frame, which enables Pay now on the main page.
- The booking is confirmed with a PNR and paid with Visa ending 1111.
- The test makes at least two assertions.
Fixtures
- Airports
- BLR Bengaluru · DEL New Delhi · BOM Mumbai · MAA Chennai · GOI Goa · HYD Hyderabad
- Today
- Tuesday, 10 November 2026 (earlier dates are disabled)
- Test card
- 4111 1111 1111 1111 · expiry 12/29 · CVV 123
- Declined card
- 4000 0000 0000 0002
- Existing booking
- PNR SW7K2Q · last name Verma
- Travellers
- Asha Verma (34, Female) · Rohan Verma (36, Male) · asha.verma@example.com · 9876543210
Playwright · Playwright Challenges · SkyWay