Skip to content
CodeKruPro

Combine a wait, a frame and an alert in one script

Automation taskMedium-HardPython onlyAsked in: Accenture, Capgemini, Infosys, Swiggy, TCS

Live rounds often end with one longer task: "Automate this flow end to end and verify it." This one mixes an explicit wait, a nested frame and an alert, with cleanup that runs even when a step fails. Say aloud where the driver is after each switch.

Combine a Wait, a Frame, and an Alert in One Script

Combine a Wait, a Frame, and an Alert in One Script

One script can visit three pages. Wait until the 5-second message is visible, read the nested child frame and return to the top document, then accept the simple alert. Print the three texts you observed. Use one function or a small page object. Assert at least one text. Quit with finally or a context manager.

Task:

  1. Wait for #appearing5sec and keep its text
  2. Read the child frame text, then return to the top document
  3. Accept the simple alert and keep its text
  4. Print the three lines and assert one of them

Aim for a reliable wait, a locator you chose yourself, and cleanup that runs even when a line fails.

Print the lines below exactly.

Expected output:

Appeared: Message appeared after 5 seconds
Frame: Child frame
Alert: This is a simple alert!