Fill a card form inside an iframe
intermediate Frames Challenge 8 of 13
The payment provider renders the card fields inside <iframe id="payment">, while the Pay button (button.pay) is in the main page. The current helper fails with NoSuchElementException on the first field.
Requirements
- Switch into the iframe before filling the fields, preferably with
ExpectedConditions.frameToBeAvailableAndSwitchToIt. Locate it by id or locator, not by index. - Fill
#card-number,#expiryand#cvcinside the frame. - Switch back with
driver.switchTo().defaultContent()before clicking Pay.
Expected output
The method switches into `iframe#payment` (located by id, not index), fills the three card fields, calls `switchTo().defaultContent()`, and then clicks Pay.
Checks (5)
- ○Switches into the payment iframe
- ○Does not switch to a frame by index
- ○Switches into the frame before filling the card number
- ○Switches back out of the frame
- ○Switches back before clicking Pay
Solution.javaValidated · not executed
Ctrl/⌘ + Enter to validate · your code is saved in this browser
Results
Validate your code against the checks.