Bird
0
0

Which sequence of commands correctly switches to frameC and clicks the button with id "btnSubmit"?

hard📝 Application Q8 of 15
Selenium Java - Handling Windows, Frames, and Alerts
You have a web page with three nested frames: frameA contains frameB, which contains frameC. You want to click a button inside frameC. Which sequence of commands correctly switches to frameC and clicks the button with id "btnSubmit"?
Adriver.switchTo().frame("frameA"); driver.switchTo().frame("frameB"); driver.switchTo().frame("frameC"); driver.findElement(By.id("btnSubmit")).click();
Bdriver.switchTo().frame("frameC"); driver.findElement(By.id("btnSubmit")).click();
Cdriver.switchTo().frame("frameA"); driver.switchTo().frame("frameC"); driver.findElement(By.id("btnSubmit")).click();
Ddriver.switchTo().defaultContent(); driver.findElement(By.id("btnSubmit")).click();
Step-by-Step Solution
Solution:
  1. Step 1: Understand nested frame hierarchy

    frameC is inside frameB, which is inside frameA, so you must switch through each level in order.
  2. Step 2: Identify correct switching sequence

    Switch to frameA, then frameB, then frameC before interacting with elements inside frameC.
  3. Final Answer:

    driver.switchTo().frame("frameA"); driver.switchTo().frame("frameB"); driver.switchTo().frame("frameC"); driver.findElement(By.id("btnSubmit")).click(); -> Option A
  4. Quick Check:

    Switch frames in order to reach nested element [OK]
Quick Trick: Switch frames stepwise from outer to inner before actions [OK]
Common Mistakes:
  • Skipping intermediate frames
  • Trying to access elements without switching frames

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes