Complete the code to switch to the iframe before interacting with elements inside it.
driver.switchTo().[1]("frame1");
To interact with elements inside an iframe, you must switch the driver's context to that frame using switchTo().frame().
Complete the code to switch back to the main page from an iframe.
driver.switchTo().[1]();After working inside an iframe, use switchTo().defaultContent() to return to the main page context.
Fix the error in switching to an alert popup.
Alert alert = driver.switchTo().[1]();To handle alert popups, use switchTo().alert() to switch context to the alert.
Fill both blanks to switch to a frame by index and then back to the main content.
driver.switchTo().[1](0); driver.switchTo().[2]();
Use switchTo().frame(0) to switch to the first iframe by index, then switchTo().defaultContent() to return to the main page.
Fill all three blanks to switch to a frame by WebElement, click a button inside it, then switch back.
WebElement frameElement = driver.findElement(By.id("[1]")); driver.switchTo().[2](frameElement); driver.findElement(By.id("submitBtn")).click(); driver.switchTo().[3]();
Find the iframe element by ID 'frame1', switch context to it using switchTo().frame(WebElement), perform the click, then switch back to main content with defaultContent().