Complete the code to switch to the first frame by its name.
driver.switchTo().frame([1]);The method frame() accepts the frame name as a string to switch context. Here, "frame1" is the correct frame name to switch to the first frame.
Complete the code to switch back to the main page from a frame.
driver.switchTo().[1]();parentFrame() which only goes up one frame.frame() instead of switching out.window().The defaultContent() method switches the driver's focus back to the main page, exiting all frames.
Fix the error in switching to a nested frame by index.
driver.switchTo().frame(0).[1](1);
switchTo() twice in the chain.defaultContent() instead of frame().After switching to the first frame by index 0, to switch to a nested frame by index 1, call frame(1) on the current frame context.
Fill both blanks to switch to a nested frame by name and then back to the parent frame.
driver.switchTo().[1]("[2]");
defaultContent to switch to a frame.First, use frame("frame2") to switch to the nested frame named "frame2". To go back to the parent frame, use parentFrame() (not shown here).
Fill all three blanks to switch to a nested frame by index, find an element by id, and then switch back to the main page.
driver.switchTo().[1](0); WebElement element = driver.findElement(By.[2]("submitBtn")); driver.switchTo().[3]();
Use frame(0) to switch to the first frame by index. Then find the element by id. Finally, use defaultContent() to switch back to the main page.