0
0
Selenium Pythontesting~10 mins

Nested iFrames in Selenium Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to switch to the first iframe by its index.

Selenium Python
driver.switch_to.frame([1])
Drag options to blanks, or click blank then click option'
Adefault_content()
B"frame1"
C0
Ddriver.find_element(By.TAG_NAME, "iframe")
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string name instead of an index.
Trying to switch to default content instead of an iframe.
2fill in blank
medium

Complete the code to switch back to the main page from any iframe.

Selenium Python
driver.switch_to.[1]()
Drag options to blanks, or click blank then click option'
Awindow
Bframe
Cparent_frame
Ddefault_content
Attempts:
3 left
💡 Hint
Common Mistakes
Using parent_frame() which only goes up one level.
Trying to switch to a frame instead of default content.
3fill in blank
hard

Fix the error in switching to a nested iframe by completing the code.

Selenium Python
driver.switch_to.frame(driver.find_element(By.[1], "innerFrame"))
Drag options to blanks, or click blank then click option'
ANAME
BTAG_NAME
CID
DCLASS_NAME
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.ID when the iframe does not have an id attribute.
Using By.TAG_NAME which selects all iframes, not a specific one.
4fill in blank
hard

Fill both blanks to switch first to the outer iframe by name, then to the inner iframe by index.

Selenium Python
driver.switch_to.frame([1])
driver.switch_to.frame([2])
Drag options to blanks, or click blank then click option'
A"outerFrame"
B1
C0
D"innerFrame"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong index for the inner iframe.
Using the inner iframe name in the first switch.
5fill in blank
hard

Fill all three blanks to find a button inside nested iframes and click it.

Selenium Python
driver.switch_to.frame([1])
driver.switch_to.frame([2])
button = driver.find_element(By.[3], "submitBtn")
button.click()
Drag options to blanks, or click blank then click option'
A"outerFrame"
B"innerFrame"
CID
DNAME
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.NAME instead of By.ID for the button.
Switching frames in the wrong order.